Reputation: 747
I have the following UserController methods:
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);
}
have cshtml page (in Views\User):
@model System.String
@{
ViewBag.Title = "SendMessageSuccess";
Layout = "~/Views/Shared/_LayoutUser.cshtml";
}
<h2>@Model</h2>
but I got:
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
after call DeleteThread. Why?
Upvotes: 0
Views: 524
Reputation: 2542
There is no problem with redirectToAction.
You are calling RedirectToAction("ActionMessageSuccess", new { txt = "Message was sent successfully" });
So it redirected to action ActionMessageSuccess with txt value.
With in ActionMessageSuccess you are returning a view with name txt i.e. "Message was sent successfully", but system unable to file a view with name "Message was sent successfully".
Upvotes: 1