MVC5:找不到资源

时间:2022-10-31 21:10:24

I am fetching data from a table and displaying it. Every row in the webpage will have a edit hyperlink. That pops up a edit window for respective row. The contents of the pop up are replaced by the @Html.Partial() function. now the form gets submitted from the Partial view. The Interesting fact is first time I edit any row it works fine. However the second time I am getting the following error:

我从表中获取数据并显示它。网页中的每一行都有一个编辑超链接。这会弹出相应行的编辑窗口。弹出窗口的内容由@ Html.Partial()函数替换。现在表单从部分视图提交。有趣的事实是我第一次编辑它正常工作的任何行。但是第二次我收到以下错误:

Server Error in '/' Application.

'/'应用程序中的服务器错误。

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

无法找到该资源。说明:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用。请查看以下网址,并确保拼写正确。

Requested URL: /Edit

请求的网址:/编辑

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.7.2623.0

           [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Edit([Bind(Include = "SerialNumber,ProjectName,Nature,Phase,StartDate,EndDate,ProjectLead,LeadAlias,Onsite,OffShore,ProjectDetail,EditedBy,CreatedBy")] ProjectModel projectModel)
          {


            projectModel.EditTime = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(projectModel).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(projectModel);

           }

The form gets submitted using the following button:

使用以下按钮提交表单:

<input type="submit" value="Save" class="btn btn-default" formaction="Edit"  formmethod="post" />

Please let me know if anything else do you need. Thanks in advance.

如果您需要其他任何东西,请告诉我。提前致谢。

1 个解决方案

#1


0  

@shyju 's answer really helped I changed the formaction and it worked

@shyju的答案真的帮助我改变了形成并且它起作用了

#1


0  

@shyju 's answer really helped I changed the formaction and it worked

@shyju的答案真的帮助我改变了形成并且它起作用了