我决定使用区域来组织我的应用程序,但现在某些表单无法提交。
控制器
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
索引和新方法都正常工作。但是我无法提交表格。
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" }
);
已解决,
如果有人遇到此问题,请确保模型中的远程属性方法链接未断开!