In vs2008, an ASP. there are two forms of Net Applications: website and webproject. First, it must be clear that these two different forms have the same results after being finally deployed to the server and compiled, they only have different organizational structures during design.
From the creation method, the difference is: one is file-> New-> Project-> Asp. NET web application; the other is file-> New-> website;
In terms of organization mode, a project file *. csproj is generated during WP type creation to record some compilation and debugging settings. The WS type does not. For WP, A project may only need a compiled DLL Assembly to respond to all application requests of the entire project. (I guess !) For WS, all parts in the project root folder are considered as part of the Web application.
In terms of compilation method: when running a WP, Vs will compile all the code and all the pages into an assembly (under the bin directory) before starting the browser ). But do not be intimidated by compiling all the code. It is said that vs uses an incremental compilation mode, and it will not be very slow. For WS, you do not need to pre-compile the code. Each page is compiled at the first request.
In details, the page command on the Web project page uses the codebehind attribute, while the codefile attribute is used on the Web Site Page to specify the code file name of the page. Example:
WP: <% @ page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. CS "inherits =" mywebproject. _ default "trace =" false "%>
WS: <% @ page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>
In addition to the aspx file and the CS file with the same name, each page in the web project also has a file named *. aspx. desinger. CS, which contains the declaration of all controls on the page. There is no such thing in a web site app. This part of the code is generated by ASP. NET during compilation.
In terms of Assembly reference, all Assembly references of WS are recorded in the web. config file, so that ASP. NET can be used for parsing references during compilation. However, assembly references in WP are stored in the project file *. csproj, and vs needs to use them when compiling code. But there are two exceptions: system. Core. dll system. Web. extension. dll references are stored in Web. config because they contain the classes required to specify new configuration settings.
Advantages of WS development:
Deployment is simple. You only need to copy the entire website directory to the web server.
It simplifies file management, allows you to add, delete, and delete any page files without editing project files or using.
It simplifies team collaboration and allows different people to write different pages, which can be put directly.
Debugging is simplified. In WP projects, the entire application must be re-compiled even if only a page is modified. In WS, each file is compiled separately, and the page is compiled only when it is requested for the first time.
Allow mixed use of languages.
Advantages of WP development:
File Management is strict, so there will be no messy things. The source code file is not required during deployment because it has been pre-compiled into the DLL. Of course, WS type can also be pre-compiled by the Pre-compilation tool before deployment.
The custom deployment process can be used with the msbuild tool to allow automatic and customized compilation of projects. In addition, the generated assembly can be more effectively controlled and appropriate names or signatures can be performed. WS generates a random Assembly name, which must be generated by using the plug-in webdeployment.
WP projects are easier to migrate.
After reading so much, one thing they have in common is that they all need to use the Web. config configuration file.
Finally, Microsoft officially recommends ws for development. Also, the interaction between WS and WP should be quite troublesome. I can see it again.