Differences between creating a Web site and creating a Web application in ASP.net

Source: Internet
Author: User
Tags visual studio 2010

Difference between creating a web site and creating a web application in asp tutorial. net

In visual studio 2010, apart from creating web applications to build your own web projects, you can also create web projects by creating web sites.

Here, the web site creation method: open the main form of visual studio 2010, select "new" | "web site" in the toolbar, in the pop-up new web site form, you can use the "asp.net tutorial web site" and "empty web site" templates to create your own web site.

In fact, Microsoft provided the web site creation function as early as visual studio 2005, which is completely web-oriented. Compared with web applications, they have the following differences:

1. Overall structure

There is no difference between web applications and general winform programs. They are all managed by project. Only files referenced by project files will appear in solution explorer, only these files are compiled. You can easily split an asp.net application into multiple visual studio projects, or exclude a file from project and source code management. Project files are managed according to namespaces. web applications can easily reference other class libraries, and they can also be referenced as class libraries, it is very suitable for the development of Project sub-templates. Therefore, some people think that web applications may be preserved by Microsoft in order to allow programmers to transition from winform to web development.

Compared with web applications, a web website adopts a completely new development structure. A directory structure is a web project. All files in this directory exist as part of the project. It abandons the concept of namespace, and web sites cannot be referenced as class libraries.

2. From the perspective of compilation and deployment

When debugging or running the web application page, you must compile the entire web project. Compiling the entire web project is usually faster, because visual studio uses the incremental compilation mode. This part is incrementally compiled only after the file is modified. Because all the class files are compiled into an application assembly, you only need to set this application assembly and. aspx file ,. the ascx file, configuration file, and other static content files are deployed together. In this model, the. aspx file will not be compiled and will be dynamically compiled only when the browser accesses this page.

All code-behind files and independent class files in the web site project are compiled into an independent application assembly, which is placed in the bin directory. Because it is an independent application assembly, you can specify the name, version, output location, and other information of the application assembly. By default, when you run or debug any web page, visual studio fully compiles the web site project, so that you can see all the errors during compilation. However, in the development process, fully compiling the entire site will be quite slow. Therefore, we recommend that you compile only the current page during development and debugging.

Based on the above description, you can choose to create a web project. If you have the following development requirements, we recommend that you create a web application to build your own web project:

To use the project management method, you need to use multiple projects to build a web application, that is, split a large asp.net project into multiple small projects.

A separate class must be used in the web page or web user control during development, and namespace should be used for management. After compilation, the name of the application assembly should be controlled.

If you have the following development requirements, we recommend that you create a web site to build your own web project:

You prefer to use the single-page code model to develop website pages, rather than using the code-behind model to compile website pages.

When compiling a page, you can dynamically compile the page to quickly see the compiling effect, and immediately see the effect without compiling the entire site.

Each page needs to generate an application assembly.

You do not need to create a project file to process a directory as a web application.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.