asp.netasp.net-mvcwebformsvs-web-site-projectvs-web-application-project

What is the difference between ASP.NET Web Forms vs ASP.NET WebSite vs ASP.NET Web Application vs ASP.NET MVC?


I am getting confused with all the different project types for developing a web solution. What is the difference between ASP.NET Web Forms vs ASP.NET WebSite vs ASP.NET Web Application vs ASP.NET MVC?

How can I check if my project is developed with ASP.NET Website or ASP.NET Web App?


Solution

  • Ok, we have asp.net web forms.

    And with webforms you have TWO types of projects

    ASP.NET WebSite

    ASP.NET WebSite applcation.

    So, both above are web forms.

    So:

    difference between ASP.NET Web Forms vs ASP.NET WebSite vs ASP.NET Web Application

    Well, both a asp.net website, and a asp.net website applcation can use and be based on webforms.

    The main differance between a asp.net website, and asp.net website applcation?

    Well, with a website, you don't have a sln project file. And while you can compile and build and run on your dev box? At publish time, you will supply BOTH the aspx pages, and the code files have to be placed on the server.

    So, IIS is the system that winds up compiling that code.

    If you use a website applcation? Well, you have a standard .net project file, and when you publish, all of the code is compiled into .dll's. (and a merge of all the many .dlls into ONE project .dll can and often does occur). What this means is that if you change ONE line of code behind? then you have to re-build, and re-publish the WHOLE project again. (since we using compiled .dll's and source code is NOT published to the web server).

    So, a LOT of developers like the asp.net website option. In fact, if you have the active and running web server on your network, then in VS you can often DIRECTLY open the active running site, and make changes. All you have to do is then ctrl-s (save) your changes - and they are now live.

    Despite this "easy" ability to make changes to the web site?

    I still VERY much prefer using a website application. and the reason then is things like setting up library code, making references to other 3rd party code, and referencing assemblies is resolved at developer and design time. So, it more like a desktop project, or console project. You can add references, and when you build, your code is converted into a .dll for the classes etc.

    With a asp.net website, then you don't get this much better compile time and developer experience in regards to setting up references and using additonal assemblies . So, I might for example be sharing a really big class that does a boatload of business rules and processing. I can share that one project (class) between several projects - including setting a reference and using that project for the asp.net web site applcation. So, you have a MUCH better experience in terms of referencing and using other projects and assemblies for a web site application. But, the cost of course is now you doing a full compile + build BEFORE you can publish. And thus even to change just one line of code in some web page, then a full re-build and compile is required for a publish tot he web site (and you have to re-publish the whole site).

    With a asp.net web? You don't even have to publish. and you can often as noted even directly open the web site files directly. Any changes made to code? You hit save, and IIS (the web site) will then re-compile that one page of code.

    So there is a thing and system called asp.net webforms.

    And with above choice of web forms, then you can choose the asp.net website, or asp.net website applcation option for development.

    MVC:

    This setup has zero to do with the web forms approach and system. So, you don't get a drag + drop, and you don't get a visual layout designer like you do with webforms.

    The also dumped automatic viewstate for controls etc., and you as a general rule will suffer MUCH less page post-backs and round trips like you have to "suffer" with webforms. But, as a result with MVC, the learning curve is FAR more steeper, and you really using much more traditional web technology and designs to build working pages. And as a result, you also increase your costs and time. MVC development is not only harder, but will cost you more time in most cases, but the results are less post-backs, results more to "web standards".

    If you come from desktop land, and are used to drag + drop design. (and then say clicking on a button to jump to the event code stub behind? Then web forms will be far easer to learn and adopt).

    However, if you want to use React, jQuery.UI, bootstrap etc.? Nothing stopping you from adopting these technology's with webforms - and by doing so, you can reduce post-backs and round trips - and quite much thus wind up with as lightweight results that MVC offers.