ASP.NET Web Site or ASP.NET Web Application?

2018-12-31 01:40发布

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.

What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other?

Is the answer different based on which version of Visual Studio I am using?

25条回答
明月照影归
2楼-- · 2018-12-31 02:03

Web Application project model

  • Provides the same Web project semantics as Visual Studio .NET Web projects. Has a project file (structure based on project files). Build model - all code in the project is compiled into a single assembly. Supports both IIS and the built-in ASP.NET Development Server. Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET (master pages, membership and login, site navigation, themes, etc). Using FrontPage Server Extensions (FPSE) are no longer a requirement.

Web Site project model

  • No project file (Based on file system).
  • New compilation model.
  • Dynamic compilation and working on pages without building entire site on each page view.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Each page has it's own assembly.
  • Defferent code model.
查看更多
刘海飞了
3楼-- · 2018-12-31 02:04

This may sound a bit obvious, but I think it's something that is misunderstood because Visual Studio 2005 only shipped with the web site originally. If your project deals with a website that is fairly limited and doesn't have a lot of logical or physical separation, the website is fine. However if it is truly a web application with different modules where many users add and update data, you are better off with the web application.

The biggest pro of the website model is that anything in the app_code section is dynamically compiled. You can make C# file updates without a full redeploy. However this comes at a great sacrifice. A lot of things happen under the covers that are difficult to control. Namespaces are difficult to control and specific DLL usage goes out the window by default for anything under app_code since everything is dynamically compiled.

The web application model does not have dynamic compilation, but you gain control over the things that I have mentioned.

If you are doing n-tier development, I highly recommend the web application model. If you are doing a limited web site or a quick and dirty implementation, the web site model may have advantages.

More detailed analysis can be found in:

查看更多
笑指拈花
4楼-- · 2018-12-31 02:04

Applications are usually compiled before deployment where as the website makes use of the app_code directory. When anything changes in the app code folder the server will re-compile the code. This means that you can add/ change code with a website on the fly.

The advantage of an app is that there is no re-compiling and so initial start up times will be faster.

查看更多
步步皆殇っ
5楼-- · 2018-12-31 02:05

Here Web Supportive Application is an example of website.

Here Web Supportive Application is an example of website. Website and Web Application both can be dynamic/static its depends upon requirements, here is an example to understand working of website's and web application.

查看更多
看淡一切
6楼-- · 2018-12-31 02:09

Definitely web application, single DLL file and easy to maintain. But a website is more flexible; you can edit the aspx file on the go.

查看更多
若你有天会懂
7楼-- · 2018-12-31 02:13

Web Site = use when the website is created by graphic designers and the programmers only edit one or two pages

Web Application = use when the application is created by programmers and the graphic designers only edit one or two paged/images.

Web Sites can be worked on using any HTML tools without having to have developer studio, as project files don’t need to be updated, etc. Web applications are best when the team is mostly using developer studio and there is a high code content.

(Some coding errors are found in Web Applications at compile time that are not found in Web Sites until run time.)

Warning: I wrote this answer many years ago and have not used Asp.net since. I expect things have now moved on.

查看更多
登录 后发表回答