If you want to develop a web application or website using Asp.Net Framework, you have 3 options:-
1. Asp.Net Webforms.
2. Asp.Net MVC and
3. Asp.Net Core
In this article, I will not discuss Asp.Net Core, simply think of Asp.Net Core as an upgrade of Asp.Net MVC. An MVC application can only be hosted on a windows platform whereas you can host an application developed using Asp.Net Core on any platform like Linux etc. You will learn everything about Asp.Net Core in the Asp.Net Core section.
Now we are left with 2 options i.e
i)Asp.Net WebForm and
Frankly speaking, Nowadays nobody uses Asp.Net WebForm to develop a brand new web application, but you should learn it, cause many applications that were developed using Asp.Net WebForms still exists, And you may face a situation where you have to work on those old projects or the requirement can be to upgrade those projects into Asp.Net MVC or Core, you will be stuck if you don't know how the application is working.
Now the question arises, when we had Asp.Net WebForm then why Microsoft came with new Asp.Net MVC.
Ok, Asp.Net WebForms was famous for almost a decade among developers because of its RAD environment. RAD stands for Rapid Application Development.
In Asp.Net Webforms we had :-
• Server Controls and
• Code behind
That is developer were able to drag and drop UI Controls called as server control to the designer area and corresponding Html were automatically generated.
Also each control were provided with events, methods, and properties, and the developer just had to set the properties and write code in the generated event in code behind .
So the development used to be faster.
In short from the developer's point of view, they had to work less to achieve more.
But, web developers make projects for clients or audiences. And the audience has nothing to do with our time.
What a client need is only a well-performing application.
And performance of any application is decided by how fast the output or result is being served meaning how fast the server is processing a request and sending the response back to the client machine or browser.
But the performance of an Asp.Net WebForm's application was not as good as it should be. The root cause was itself the RAD environment.
Each time the server controls needed to be converted into Html called rendering.
Also with each control the ViewState was enabled by default to maintain the state. This ViewState used to generate a huge amount of bytes, which increases the page load and makes it slower.
The other disadvantages of using Asp.Net Webforms are :-
1. Its Page first architecture, meaning the request always comes to the page and unnecessarily goes to the complicated page life cycle even when it is not needed. Meaning, the physical presence of the page is necessary.
2. The Aspx page (Design) and Aspx.cs (code/code-behind) are dependent on each other, meaning are tightly coupled because that same view can not be used with different code and different code can not be used with another view.
3. The code-behind page i.e the Aspx.cs page is inherited from System.Web.UI.Page, which makes it a special page and unlike a normal class its object can not be created. So, No re-usability of code is there.
The code written in the button click event under one page can not be reused in other pages by creating the object of the desired event containing the page.
4. Sending a response other than Html is hectic work, and Html is the only preferred response type.
Due to all of the above reasons Microsoft Launched Asp.Net MVC with
• No Server Controls meaning no extra time for html conversion.
• No code behind meaning better reusability of code.
Asp.Net MVC is nothing but a technology that follows the MVC architectural pattern, which gives the best separation of concern. Where your Aspx page becomes view and Code behind becomes Controller which is a simple class, which gives the flexibility of Unit Testing and Re-usability.