[ASP. NET] differences between ASP. NET web site and ASP. NET web application

Source: Internet
Author: User

During the interview, I usually ask the examinee this question, and the results are usually disappointing. In fact, many of them have been developed with ASP. NET for many years.ProgramPersonnel are not very clear about this issue.

Why should I explain this problem? In fact, this problem does not have much impact on ASP. NET development, but if we can correctly understand the differences between the two, it can also help us solve many problems encountered during the development process.

First, let's start with how to create these two projects. See the following two. I use Visual Studio 2010, and Visual Studio 2008 has a similar layout.

As shown in the arrow, here is how to create an ASP. NET web site project.

 

To create a web application, you need to create two parts, as shown in. Select project first, and then select ASP. NET web application from the Web tag.

Both projects can be directly copied to the server and deployed as websites without any difference in performance. However, from the perspective of the structure, compilation, and programming methods, we will see the differences. Here we will explain them one by one.

1) namespace

Namespace is one of the most obvious differences between the two projects. We will discuss C #, VB. net is special, and its namespace will be automatically added. Therefore, we do not need to write the namespace during the compilation of these two projects.

By default, in ASP. net c # web site, we do not need to write namespace. We can try to create a new page and view its code page. However, all web applications require a namespace. Of course, we can also add namespace for the web site. When we use servicereference of scriptmanager, in the application, we need to add namespace to call WebService with Js. For more information about how to use servicereference, see my other article.Article.

2) Compile and Output

ASP.. NET web site will be automatically compiled every time it is run. Therefore, when we use vs for development, we do not need to make any changes to rebuild the project, we can directly debug the results in the browser. However, if the web application involves code behind modifications, it must be rebuild the project before the modifications can be applied. The reason is that the compilation output of the web site is not under the current project, but a Unified Address: % SystemRoot % \ Microsoft. net \ framework \ version \ temporary ASP. net files, and after pre-compilation, the output will be transferred to the bin directory of the web site. On the issue of pre-compilation, we can refer to this link: http://msdn.microsoft.com/en-us/library/399f057w (vs.85). aspx, we recommend that you can pre-Compile when releasing the website, this will help the running speed, also conducive to post-maintenance. After the web application is compiled, it is directly output to the bin directory.

3) app_code

Only ASP. NET web sites have app_code. We usually put all the class files shared in the web site in this directory. the compiler will automatically compile the class files in app_code into assembly.

4) assemblyinfo

ASP. NET web application has assemblyinfo, but the web site does not.

5) property pages (Project Properties)

There is a big difference between the two when modifying project properties. The Web application has the same settings and layout as other created applications. However, the web site is much simpler.

 

Summary:

In fact, Microsoft set up ASP. NET web application because it received feedback from many developers. In the early days, vs2003 applications could not be successfully transplanted to the vs2005 web site model, especially when pre-compiling sites, multiple assemblies may be claimed. Through web application, developers can treat websites as common applications. Some people think that the Web site is easy to use, and some people think that the Web application is easy to use. In fact, Microsoft has set up these two project models to give us an alternative, you can create a web project based on your preferences.

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.