0

请求 ["fileName"] 返回 null?? 为什么?

鼠标悬停链接

完整图片:http: //i.stack.imgur.com/U1MzX.jpg

控制器:

动作删除

完整图片:http: //i.stack.imgur.com/DCQNG.jpg

路线

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" }
    );

}

区域登记

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" }
        );
    }
}
4

2 回答 2

0

您的控制器操作应采用“fileName”参数,而不是执行 Request["fileName"]。只要您的查询字符串参数与控制器中的参数名称匹配,mvc 就应该自动传递它。

于 2012-07-08T16:28:53.203 回答
0

如果 Remover 是一个 MVC 操作,那么我在 Remover Action 中看不到名为 fileName 的参数

这意味着当调用 Remover 操作时,查询字符串中的文件名没有自动绑定模型

于 2012-07-08T16:23:13.903 回答