0
我有以下UserController的方法:奇怪MVC RedirectToAction的行为
public ActionResult DeleteThread(int RootMessageID)
{
_repository.DeleteMessageThread(RootMessageID);
return RedirectToAction("ActionMessageSuccess", new { txt = "Message was sent successfully" });
}
public ActionResult ActionMessageSuccess(string txt)
{
return View(txt);
}
有CSHTML页面(在浏览\用户):
@model System.String
@{
ViewBag.Title = "SendMessageSuccess";
Layout = "~/Views/Shared/_LayoutUser.cshtml";
}
<h2>@Model</h2>
但我得到:
The view 'Message was sent successfully' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/User/Message was sent successfully.aspx
~/Views/User/Message was sent successfully.ascx
~/Views/Shared/Message was sent successfully.aspx
~/Views/Shared/Message was sent successfully.ascx
~/Views/User/Message was sent successfully.cshtml
~/Views/User/Message was sent successfully.vbhtml
~/Views/Shared/Message was sent successfully.cshtml
~/Views/Shared/Message was sent successfully.vbhtml
之后调用DeleteThread。为什么?
没有什么明白。我看到,我传递了actionName =“ActionMessageSuccess”和routeValues =“new {txt =”消息已成功发送“}”。所以,方法ActionMessageSuccess应该用参数txt =“消息发送成功”来调用。我错在哪里? – John 2012-02-17 15:34:50
哦,我发现问题了。谢谢! – John 2012-02-17 15:41:21