web application projects v.s. web site projects [d

2019-01-23 21:40发布

This question already has an answer here:

I am reading from the following link,

http://reddnet.net/code/asp-net-web-site-vs-web-application-project-part-2/

My two confusions,

  1. What is the so-called issue "No control over your namespaces" cons from a web site project? Could anyone show me a sample to illustrate this issue please?

  2. What is the so-called issue "It is hard (read, nearly impossible) to reference pages, user controls, etc from custom classes in the app_code folder."? Could anyone show me a sample to illustrate this issue please?

I am using VSTS 2008 + .Net 3.5 + C#.

thanks in advance, George

1条回答
戒情不戒烟
2楼-- · 2019-01-23 22:19

imagine a WebSite...

that is a simple web app, all alone in the world... remember, you can't add anything else to it, right...?

Now, how about a web project? that it's part of a Solution, and a Solution can have n projects, take my current work for example:

alt text http://www.balexandre.com/temp/2009-06-29_0816_so_question.png

In just one solution, I have more projects than the website, and even if they are in different directories I referenced those projects in the website and it's easy to edit, for example, the ExtensionMethods project when I need to add more.

This is something that you can't control in a WebSite, only in a Web Application Project.

The Web Application Project is like any other project, it includes all files that are in Projects like the proj extension file, and it's treated like a project, for example, you can exclude files to be compiled (you can't in a Website), it is easier to deploy because of the nice plugin called Web Deployment Project", just right click in your WebSite project and choose Add Web Deployment Project...

alt text http://www.balexandre.com/temp/2009-06-29_0825_soanswer.png

And you can deploy only this project (add it to your Web Setup, in order to create the msi file) and you will deploy a compiled website (no source code is showed, all code is compiled into dll's so you can hide the source).

There are numerous advantages to use Web Application Project over a simple Website...

查看更多
登录 后发表回答