Why MVC Framework? How different from ASP.NET?

+1 vote
asked Jun 18, 2013 in ASP.Net MVC by John

So far I worked as a ASP.NET developer for a long time and soon getting chance to work with ASP.NET MVC framework. But before that, I would really like to understand the background of MVC Framework. Where there is a successful framework (ASP.NET) out there, why Microsoft came up with this new framework? Is it replacement of ASP.NET? How MVC is different from ASP.NET and what are key benefits we get?

Share

1 Answer

+1 vote
answered Jun 18, 2013 by Aadhira (1,213 points)
edited Jul 8, 2013 by Aadhira
 
Best answer

First of all ASP.NET MVC is not a replacement for regular ASP.NET. Both are completely different the way how the requests are processed when it comes from web browser. So, now we have 2 different frameworks to develop web application. ASP.Net MVC does not have Page Life Cycle at all. Even though I say both are different frameworks, ASP.NET MVC developed on top of ASP.NET. So, MVC framework will also be using ASP.NET Run time to process the request. You still can use Master pages, Handlers, HTTPRequest, Caching, Providers etc. But the way how MVC Framework process the request is different than regular ASP.NET.

The reasons I think why Microsoft came up with this new framework are listed below.
1. Separation of concerns
2. Unit testing support
3. Clean URL support

Separation of Concern:
As you might know, developers always try to implement code by keeping the separation of concern in mind. That way the responsibility of each component will be separated from other. Code looks clean. We know which component do what? Also, it gives us better extensibility. If you look at the normal ASP.NET, we have Page Life Cycle, the same aspx page is responsible for maintaining the state of that page, it is responsible to talking to Business layer and some file systems to get data and construct the page and send the response back. But with new MVC Framework, we have Model – Maintains the state of the objects used in the domain, Controller is the one responsible to process the request and talks to the right business layer to get model, then send the model to the right View. View – Responsible to dealing with html and model to give the correct html response for the request. So, now each has its own functionality.

Unit Testing Support:
Since we have great separation of concern implemented in MVC Framework, we also have the MVC Framework works with Interface instead concrete classes. Whenever there is a interface, then we have chance for great extensibility and unit testing. So, now we easily unit test the controller without having the aspx view. Same line that Model can be unit tested separate.

Clean Url Support:
Now days, all web developments are not only targeting customers, but also targeting Search Engines. Search engines are better works with Clean URL. Usually the URLs will have the query string with “?”, lots of parameters etc. Which is not very clear to understand, where we are? What kind of information it may have etc. But with the clean URL you can easily assume, in which page use are, what kind of information you may expect also, there is a very good navigation based on the hierarchy. Without clean URL, you may not know how to move on to the upper lever of the URL. But now, it is very easy.
Example: If your URL is as below how do you know what would be the URL for the upper level

Unclean Url:

http://example.com/index.php?mod=profiles&id=193

Clean Url:

http://example.com/profiles/193

By looking at the clean Url, you can easily say that you are in a profile page with the profile id 193. If you want to see list of all profiles, then you can use the below Url.

http://example.com/profiles/

See how clean it is. I think, these are the basic reasons that I think Microsoft came up with new framework. There could be other reasons. For more information, please refer

http://msdn.microsoft.com/en-us/library/dd381412(v=vs.90).aspx

Your answer

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015 pinfaq.com
...