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.A MVC application can only be hosted on 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 Asp.Net Core section.
Now we are left with 2 options i.e
i)Asp.Net WebForm and
Frankly speaking, Now a days 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 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 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 were 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 controls 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 developer's point of view ,they had to work less to achieve more.
But,we developer make projects for client or audience.And 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 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 as 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 page is necessary.
2. The Aspx page (Design) and Aspx.cs (code/code-behind) are dependent on each other , meaning are tightly coupled,because of that same view can not be used with different code and different code can not be used with other 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 create. So,No re-usability of code is there.
The code written in button click event under one page can not be reused in other pages by creating the object of desired event containing page.
4. Sending response other than Html is hectic work ,and the Html is 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 which follows 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.