[英]How do I post a message to confirm a sent message after a page redirect (C#/ASP.Net)
[英]Cant find page after POST redirect C#
我转到一个View,通过POST提交数据,但是重定向找不到Controller方法。 我在这里做错了什么? 提交表格后,我得到:
404 error: cannot find page. URL is: http://localhost:52008/InternalController/UpdateCardFormPost
来自InternalController.cs的代码段:
public ActionResult UpdateCardFormView()
{
var CardToUpdate = new CardView();
return View(CardToUpdate);//return implementation of Cards.cshtml with the empty model that was passed to it
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult UpdateCardFormPost(CardView c)
{
CardModelIO.WriteCard(c);//@TODO: IMPLEMENT
return View("CardDetailView", c);
}
UpdateCardFormView.cshtml(具有我提交的表单的视图):
@using LeanKit.API.Client.Library.TransferObjects
@model CardView
<!DOCTYPE html>
<html>
<!--Form used to change a card
STARTING DISPLAY called by in Internal/UpdateCardFormView
ENDING DISPLAY (post) called by UpdateCardForm in InternalController a specified below-->
<head>
</head>
<body>
@Html.BeginForm("UpdateCardFormPost", "InternalController", FormMethod.Post)
@Html.TextBoxFor(c => c.AssignedUserName);
<input type="submit" value="Submit Changes" />
</body>
</html>
这是CardDetailView.cshtml(应将我重定向到的视图):
@using LeanKit.API.Client.Library.TransferObjects
@model IEnumerable<CardView>
<!--used for displaying an individual card in detail view
referenced in UpdateCardFormPost() method of Internal controller-->
<!DOCTYPE html>
<html>
<head>
</head>
<body>
CardView j = Model;
<p>j.AssignedUserId</p>
</body>
</html>
您已将控制器名称指定为InternalController,但它可能只是称为“ Internal”。
尝试改变
@Html.BeginForm("UpdateCardFormPost", "InternalController", FormMethod.Post)
至
@Html.BeginForm("UpdateCardFormPost", "Internal", FormMethod.Post)
您缺少关闭表单标签
你应该这样做
using (@Html.BeginForm("UpdateCardFormPost", "InternalController", FormMethod.Post))
{
...
}
@using(Html.BeginForm()){
@Html.TextBoxFor(c => c.AssignedUserName);
<input type="submit" value="Submit Changes" />
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.