0

Request ["fileName"] return null?? Why?

Link on mouseover

Full image: https://i.stack.imgur.com/U1MzX.jpg

Controller:

Action remove

Full image: https://i.stack.imgur.com/DCQNG.jpg

Route

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        "AdminLogin",
        "Admin/",
        new { controller = "Account", action = "Login" }
        );


    //NossaIgreja/{nomePastor}
    routes.MapRoute(
        "Pastor", // Route name
        "Pastor/{id}", // URL with parameters
        new { controller = "NossaIgreja", action = "Pastor" } // Parameter defaults
        );

    routes.MapRoute(
        "Download", // Route name
        "Downloads/Boletim/{year}/{week}", // URL with parameters
        new { controller = "Downloads", action = "DownloadBoletim" },  // Parameter defaults
        new { year = @"\d+", week = @"\d+" }
        );

    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        , new string[] { "SextaIgreja.Web.Controllers" }
    );

}

Area registration

public class AdminAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get
        {
            return "Admin";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Admin",
            "Admin/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional },
            new string[] { "SextaIgreja.Web.Areas.Admin.Controllers" }
        );
    }
}
ridermansb
  • 10,779
  • 24
  • 115
  • 226

2 Answers2

0

If Remover is an MVC action than I cannot see the parameter in Remover Action called fileName

It means when call Remover action the fileName in your querystring is not getting automatic model binding

HatSoft
  • 11,077
  • 3
  • 28
  • 43
  • It is required that the parameter "fileName" is in the parameters of the action? If yes, why the parameter "tipo" is listed in `Request.QueryStrings` ? The parameter "tipo" is the url that is active. (current page) and not the action I just click! – ridermansb Jul 09 '12 at 18:53
0

Your controller action should take "fileName" parameter, instead of doing a Request["fileName"]. As long as your query string parameter matches the name of the parameter in your controller mvc should pass it in automatically.

Mitchell Lee
  • 456
  • 3
  • 14