Advantages of MVC over WebForms
Webforms has
code behind
andPage Lifecycle Events
. Every action on the page has to go through an expensive lifecycle events before finally executing the action or method associated with the user's event.Also, the code you write in an Element's event (e.g Button_Click event on an aspx page) is not reusable
In MVC, a user action's hit is directly received in Controller's action. Thus there is no expensive lifecycle events execution involved.
Also, the controller's action now carry the code of some action event and thus can be reused in multiple requirements.
With MVC, the response sent back from a Controller's action can be a HTML view, or JSON or XML. But in Webform, you only have aspx's processed HTML response back. To send back JSON or other content, a lot of configuration needs to be done.
Unit testing becomes easy with MVC , its very complex to test aspx code behind but in MVC, controller's and model's being simple classes, its easy to unit test those.
Last updated
Was this helpful?