没有提交区域的BeginForm

时间:2015-06-18 15:30:24

标签: asp.net-mvc routing html.beginform areas

我决定用区域组织我的应用程序,现在有些表格不会提交。

控制器

public class SoftwareInfoController{
    public ActionResult Index(){...}
    public ActionResult New(){...}
    [HttpPost]
     public ActionResult Save(SoftwareInfoViewModel viewModel){...}
}

我可以像这样访问视图,"包装"作为一个区域

webpage.com/Packaging/SoftwareInfo/Index
webpage.com/Packaging/SoftwareInfo/New

Index和New方法都正常工作。但我无法提交表格。

edit.cshtml
@model SoftwareInfoViewModel 
...
@using (Html.BeginForm("Save","SoftwareInfo")){...} // does nothing
@using (Html.BeginForm("Save","SoftwareInfo", FormMethod.Post)){...} // does nothing
@using (Html.BeginForm("Save","SoftwareInfo", new {Area = "Packaging" })) {...}// does nothing

路由

    context.MapRoute(
    name: "Packaging_default",
    url: "Packaging/{controller}/{action}/{id}",
    defaults: new { controller = "Editor", action = "Index", id  =UrlParameter.Optional },
    namespaces: new[] { "WebApp.Areas.Packaging.Controllers" }
    );

1 个答案:

答案 0 :(得分:0)

解决,

如果有人遇到此问题,请确保您的模型中的远程属性方法链接没有损坏!