Explain how asp.net mvc different from webforms

Views: 285
Created Date: 02-Oct-2016

Web forms uses page controller or base controller design pattern where as MVC uses Front Controller design pattern.

 

Page Controller:

Page receives request from IIS and call controllers method. In traditional web forms all pages (View) inherit from System.Web.UI.Page class which has a code behind class acting as a controller.

 

Base Controller:

As a thumb of designing and architecture we should never inherit from base class directly and rather should provide a level of indirection by introducing our base types. In Base controller we create an abstract class that inherits from System.Web.UI.Page and use that as base class for all aspx pages.

 

Front Controller:

Controller received request from IIS and transfer to View. Controller has action methods which may return a view or any of available ViewResults defined below

 

Results returned by Action methods:

 

Actions in Asp.Net MVC returns ActionResult which is base class for all the results that can be returned. Below are classes that derive from ActionResult and can be returned as a result.

  1. ViewResult
  2. PartialViewResult
  3. ContentResult
  4. JsonResult
  5. JavascriptResult
  6. EmptyResult
  7. FileResult
  8. FilePathResult
  9. FileContentResult
  10. FileStreamResult
  11. HttpNotFoundResult
  12. HttpStatusCodeResult
  13. HttpUnAutorizedResult
  14. RedirectResult
  15. RedirectPermanentResult
  16. RedirectToActionResult
  17. RedirectToActionPermanentResult
  18. RedirectToRouteResult
  19. RedirectToRoutePermanentResult

Similar Tags
4.5 22