BeginForm呈现空白操作方法

问题描述

| 问题是,每当我在BeginForm中对Action和Controller进行硬编码时,都会导致空白的action方法。 我很困惑。 下面的视图已从HomeController和Index操作方法调用
@using (Html.BeginForm(\"Index\",\"Home\",FormMethod.Post,new { id = \"first\" }))
{}
结果
<form id=\"first\" method=\"post\" action=\"/Home\"></form>
下面的视图已从HomeController和Page动作方法调用
@using (Html.BeginForm(\"Edit\",new { id = \"first\" }))
{}
结果
<form id=\"first\" method=\"post\" action=\"\"></form>
路由
    routes.MapRoute(
        \"RootUrlWithAction\",new
            {
                controller = \"Home\",action = \"Index\",name = \"home\",id = UrlParameter.Optional
            }
    );

    routes.MapRoute(
        \"DynamicPages\",\"{name}/{id}\",action = \"Page\",id = UrlParameter.Optional
            }
    );

    routes.MapRoute(
        \"EmptyUrl\",\"\",name = \"home\"
            }
    );

    routes.MapRoute(
        \"Default\",\"{controller}/{action}/{name}/{id}\",new
        {
            controller = \"Home\",name =  UrlParameter.Optional,id = UrlParameter.Optional
        } 
    );
控制器动作
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Page(String name)
    {

        return View();
    }

    [HttpPost]
    public ActionResult Edit(Order orderVm)
    {
        var a = orderVm;
        string errorMessage = \"hehehe\";

        return Json(new Order { Message = errorMessage });
    }
}
    

解决方法

        您应该尝试使用可以从NuGet下载的此工具调试路由。 http://haacked.com/archive/2011/04/13/routedebugger-2.aspx   PM>安装包RouteDebugger 让我知道它如何为您服务。