An MVC Gotcha and the PRG Pattern
If you’ve recently moved across to ASP.NET MVC development following years of wrangling with the leaky abstraction that was WebForms, you may have encountered some seemingly curious behaviour when posting back to the same URL. Suppose we have the following simple, contrived and utterly imagination-free model: Here’s a view: And here’s the controller: Note that we have two separate Index actions – one for HTTP GET which instantiates and displays a new FooModel instance, and one for HTTP POST which modifies one of the properties on the posted FooModel instance before re-rendering the view. ...