Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I re-direct to different pages using the same controller ActionResult?
    primarykey
    data
    text
    <p>I have two views using the same ActionResult. There was originally only one view but now there is the need for a second.</p> <p>The views are - "Index" &amp; "Accepted" Index</p> <pre><code> [HttpGet] public ActionResult Index(string status, string message) { var InboxStatus = InboxStatus.New; if (!Enum.TryParse(status, out inboxStatus)) inboxStatus = InboxStatus.New; var model = new InboxModel(); model.Status = inboxStatus.ToString(); model.InboxMailCount = GetInboxMailCount(); model.InboxMailCount.Status = InboxStatus.ToString(); @ViewBag.Message = message; return View(model); } </code></pre> <p>Accept</p> <pre><code> [HttpPost] [ValidateAntiForgeryToken] public ActionResult Accept(InboxModel model) { if (ModelState.IsValid) { var inboxmail = _repo.GetById(model.ID); inboxmail.Status = (int)ReferralStatus.Accepted; inboxmail.AcceptedByUserId = UserId; inboxmail.AcceptenceDateTime = DateTime.Now; _uow.SaveChanges(); return RedirectToAction("Index", new { Message = "Accepted Successfully" }); } return View(model.ID.ToString()); } </code></pre> <p>The ActionResult is called "Declined", The problem is that the Action Result contains the following... </p> <pre><code> [HttpPost] [ValidateAntiForgeryToken] public ActionResult Decline(InboxModel model) { if (ModelState.IsValid) { var InBox = _repo.GetById(model.ID); InBox.Status = (int)ReferralStatus.Declined; InBox.DeclinedByUserId = UserId; InBox.DeclinedDateTime = DateTime.Now; _uow.SaveChanges(); return RedirectToAction("Index", new { Message = "Declined Successfully" }); } return Accept(model.ID.ToString()); } </code></pre> <p>So if the user select's the "Declined" action on either page they will be re-directed to "Index" regardless of them carrying out the action on the "Accepted" view. Make sense,? I want to re-direct them back to the page they came from.</p> <p>Please note this is how I am currently re-directing to "Accepted" for different action...</p> <p>As the lists in Index depend on the "Status" property... Index view..</p> <p>ASP.Net MVC 4 using razor 2 views.....any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload