c# - Post/Redirect/Get Pattern in ASP.NET MVC -


What is the best practice to implement post / redirect / gate pattern in ASP.NET MVC?

  1. Specifically, when you want to redirect the initial action / controller back then what is the best way to do this

    Display the form for the user < Ul>

  2. In the form, and % = Html.Hidden ("returnUrl")%> to use
  3. In action, ViewData ["ReturnUrl"] = Request.Url;
  4. User submits form via post
  5. returnUrl model binding, if not < Code> null . Otherwise, redirect to the homepage.

This work has been done, but it seems that it will result in much more repetition. I also realized that I might have to Request.UrlReferrer ...

, what is to do, is this the ideal way to accomplish this?

The way you are doing it is fine, but it seems that you have a bit of it Can overhauling. Does your post action take posts from more than one form? If not, why bother with the hidden field? You can get away from a simple Redirection Tiection ("Mayation")


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -