Search code examples
asp.nethttp-redirectseparation-of-concernsmvp

Most Correct way to redirect page with Model-View-Presenter Pattern


What is the best way to call a Response.Redirect in the Model-View-Presenter pattern while adhering to correct tier separation?


Solution

  • One way I handled this is for the presenter to raise an event (like Succeeded or something) that the view would subscribe to. When the presenter finished it's processing, it would raise the event, which would get handled by the View. In that handler, the view would redirect to the next page.

    This way, the presenter doesn't need to know anything about pages or URLs or anything. It just knows when it has completed its task and lets the view know by raising an event. You can raise different events if the presenter succeeded or failed, in case you need to redirect to different places.