C# 为什么我的按钮没有在控制器中调用操作?

C# 为什么我的按钮没有在控制器中调用操作?,c#,asp.net,asp.net-mvc,asp.net-mvc-4,asp.net-web-api,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Asp.net Web Api,我有EDITSTORIES部分视图,它必须将数据发布到Stories控制器中的UpdateStores操作,但它没有。它甚至没有达到断点 @using (Html.BeginForm("UpdateStories", "Stories", FormMethod.Post, new{enctype = "multipart/form-data" })) { @Html.AntiForgeryToken() <div class="form-horizontal">

我有EDITSTORIES部分视图,它必须将数据发布到Stories控制器中的UpdateStores操作,但它没有。它甚至没有达到断点

@using (Html.BeginForm("UpdateStories", "Stories", FormMethod.Post, new{enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Stories</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.Image, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Image, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Image, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Story, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Story, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Story, "", new { @class = "text-danger" })
            </div>
        </div>


        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Update" class="btn btn-default" />
            </div>
        </div>
    </div>
}
它位于GetStories中,这是主视图。这是漫长的一天,但仍然没有完成。请帮帮我

更新:

路线:

  routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Stories", action = "AddStories", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "ShowStories",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Stories", action = "ShowStories", id = UrlParameter.Optional }
            );
更新:

视图:GetStories

@model HimHer.Models.Stories

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (@Html.BeginForm("GetStories", "Stories", FormMethod.Get))
{
        @Html.AntiForgeryToken()

    <div style="@ViewBag.Style">
        @{
            Html.RenderPartial("EditStories", Model);
        }


    </div>

    <hr />
    var listData = (List<HimHer.Models.Stories>)ViewBag.Grid;

    WebGrid wgImages = new WebGrid(listData, rowsPerPage: 20);
    @wgImages.GetHtml(tableStyle: "table table-condensed table-bordered table-striped table-responsive",
columns: wgImages.Columns(
                      wgImages.Column
                      (columnName: "Image", header: "Image"),
                      wgImages.Column
                      (columnName: "Story", header: "Story"),
                      wgImages.Column
                      (columnName: "Image", header: "Download", format: (testItem) => Html.ActionLink("Download", "DownloadStories", new { filename = testItem.Image })),
                      wgImages.Column
                                         (header: "Edit", format: (testitem) => Html.ActionLink("Edit", "EditStories", new { ID = testitem.ID, Story = testitem.Story, Image = testitem.Image, HiddenID = 1 }))
                     )
);



}

<h2>Index</h2>
@model-HimHer.Models.Stories
@{
ViewBag.Title=“Index”;
Layout=“~/Views/Shared/_Layout.cshtml”;
}
@使用(@Html.BeginForm(“GetStories”、“Stories”、FormMethod.Get))
{
@Html.AntiForgeryToken()
@{
RenderPartial(“EditStories”,模型);
}

var listData=(List)ViewBag.Grid; WebGrid wgImages=新的WebGrid(listData,rowsPerPage:20); @GetHtml(tableStyle:“表压缩表带边框表带条表响应”, 列:wgImages.columns( wgImages.Column (列名:“图像”,标题:“图像”), wgImages.Column (专栏名称:“故事”,标题:“故事”), wgImages.Column (columnName:“Image”,标题:“Download”,格式:(testItem)=>Html.ActionLink(“Download”,“DownloadStories”,new{filename=testItem.Image}), wgImages.Column (标题:“编辑”,格式:(testitem)=>Html.ActionLink(“编辑”,“编辑故事”,新{ID=testitem.ID,Story=testitem.Story,Image=testitem.Image,HiddenID=1})) ) ); } 指数
您的代码将生成两个表单,它们是嵌套的

<form action="/Stories/GetStories">
   <form action="/Stories/UpdateStories">
      <input type="submit" />
   </form>
</form>

您的代码将生成两个表单,它们是嵌套的

<form action="/Stories/GetStories">
   <form action="/Stories/UpdateStories">
      <input type="submit" />
   </form>
</form>

表单post响应的状态代码是什么?您在问题中没有显示您的路线。或者控制器的名称。@mason udpated和contoller是STORIES@Jasen:没有,这会让我回到GetStories这就是问题所在!您不能有嵌套表单!!!!表单post响应的状态代码是什么?您在问题中没有显示您的路线。或者控制器的名称。@mason udpated和contoller是STORIES@Jasen:没有,这会让我回到GetStories这就是问题所在!您不能有嵌套表单!!!!
@using (@Html.BeginForm("GetStories", "Stories", FormMethod.Get))
{
   <!-- Some form elements needed for this form -->     

}

@{ Html.RenderPartial("EditStories", Model); }