Why ASP MVC is much better than ASP.Net WebForms?

asp.net vs mvc

If you are or you want be Asp Web developer, you must know about ASP.Net MVC and reasons why it is much better than ASP.NET Web Forms.

ASP.NET is the biggest success of Microsoft and it successfully delivered Web Application for past 12 years. It is easier for a web developer to develop web forms using asp.net than other architecture. A developer can drag and drop the control onto web forms and visual studio automatically generates event-based code behind the control. So, the programmer can easily write code on the click_event of control. It seems so pleasant to developing the project over asp.net but there is some serious problem with asp.net so, Microsoft decided to overcome these problems by launching ASP.Net MVC.

1

So, whats the problem with ASP.Net?

There are some serious problem with ASP.Net architecture that is listed below.

  1. Performance Issue: net has slower server response, huge and complex page cycle life and consumes heavy bandwidth.
  2. Server Control: If you are an asp.net developer you might know about server control. Now, the simple question is why need to server control if you have light weight html control in hand. Microsoft cleverly shows you that you are working on event driven programming architecture but in reality a server control converts itself into a simple control. For example:
ASP.NET VS MVC

If you drag a text box in web forms you see the following code in .aspx file

<asp:TextBox ID="TextBox1" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
            TextBox1.Text = "Make it simple";
            TextBox1.BackColor = Color.Aqua;
}

But what actually happened behind it? If you see the original output of the above code you get this code.

<input name="TextBox1" type="text" value="Make it simple" id="TextBox1" style="background-color:Aqua;" />

So, the question is why need to do more server trip for a simple control if you have handy html control to work. And just imagine what happened if you have dozens of control on the page. The page becomes slow and unresponsive several time. It is a biggest headache for end user.  So, the solution is get rid of Server Control.

Introducing ASP.net MVC

Now, let’s discuss about ASP.net MVC Architecture.  MVC stands for Model, View and Controller.

Model: It is middle layer between View and Controller.
View: It is pure HTML Design
Controller: It contains all the coding logics.

So, How MVC works?

Steps 1: User first clicks a button and the request goes to the controller. Don’t forget that controller is an area where your programming logic resides.
Steps 2: Based on request Controller creates the object of the Model. Model invokes data access layer which fetches data from the Model.
Steps 3: Now the model which is loaded with data; passed to view for display purpose.

Features of ASP.Net MVC

  1. It is lightweight and follows Model, View and Controller based architecture.
  2. It has not server control instead a designer can design a page in pure HTML and CSS.
  3. Microsoft removes View State in MVC.
  4. In MVC, Views and Logic are kept separately.
  5. It has no Master Page instead MVC has Layouts for consistent look and feels.
  6. Net MVC is an Open Source.

Suggestion:

In my suggestion if you are an ASP.Net Developer you must upgrade yourself with MVC. For Beginner -skip learning ASP.Net Web Forms (because it is outdated) and start learning MVC.

 

Share your thought