0
votes

I have a Details and Edit page from where the user can send out an email by clicking on a email hyperlink.

When they click on the Details or Edit page hyperlink, I go to the controller which opens up an email that the user can edit.

On submit of the email, I go to the [httppost].

On the httppost actionresult, I need to use the return RedirectToAction in order to redirect the user back to either the Edit or Details page from where they started from.

I was thinking of keeping this information in a session variable as to where the user originated from:

   Session["Originated"] = "Edit";

or

   Session["Originated"] = "Details";

Or is there a better way to keep track of this.

1

1 Answers

2
votes

Maybe add route parameter? For example /Email/Create?originated=Edit. It will keep all your stuff sessionless.

Example: In View

 @Html.ActionLink("Create email", "Create", "Email", new { originated = "Edit" }, null)

In Action

public ActionResult Create(string originated)
{
...
}