【问题标题】:BeginForm with areas don't submitBeginForm 区域不提交
【发布时间】:2015-06-18 15:30:24
【问题描述】:

我决定使用区域来组织我的应用程序,但现在有些表单无法提交。

控制器

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

【问题讨论】:

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


    【解决方案1】:

    解决了,

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多