When you surf the Internet, have you ever seen the following thing?
As a web developer, we know what it means--the form has been posted to the page, but is trying to refresh the same page. I don't know if it's significant to study the subject, but I can imagine that my grandmother certainly didn't know what to do when she met the picture. Use PRG mode.
What is the PRG mode?
Although the PRG model is not something new, it's in. NET community has not emphasized much. PRG says "Post/redirect/get" and the rest is for Wikipedia to explain:
Instead of returning directly to an HTML page, the post operation returns a redirection command (using the HTTP 303 response code (sometimes 302) and the HTTP "Location" response header) to boot the browser to load another page with an HTTP GET request. This result page can be safely saved or reloaded as a bookmark without unintended side effects.
Although WebForms can do this, it is very complex, because the postback model of the page needs to be back-made to implement the click of the button. The MVC framework makes it very easy to implement the PRG pattern.
How do you do it? Give me an example?
I'll use a login function as an example. If the login succeeds, the user will be redirected to his account page, otherwise it will be redirected back to the login page.