简体   繁体   English

ASP.net:网站或Web应用程序项目

[英]ASP.net: Website or web application project

Is there any difference between website and web application project? 网站和Web应用程序项目之间有什么区别吗? What if you are working on a project that is sort of hybrid of site and application? 如果您正在处理一个混合了站点和应用程序的项目,该怎么办? which project should you chose? 你应该选择哪个项目?

I'ld go the newer Web Application project (always, regardless of the size of the project). 我会去更新的Web应用程序项目(总是,无论项目的大小如何)。

There is nothing to lose and everything to gain with using the Web Application Project (you cannot say this about using the "website" only). 使用Web应用程序项目没有任何损失和一切可以获得(您不能仅仅使用“网站”这样说)。

The official list of differences are here: 正式的差异清单如下:

Use Web Application Projects when you 在您使用Web应用程序项目时

  1. Need to migrate large Visual Studio.NET 2003 applications 需要迁移大型Visual Studio.NET 2003应用程序
  2. Need to control names of output assemblies 需要控制输出程序集的名称
  3. Need stand-alone classes to reference page and user control classes 需要独立类来引用页面和用户控件类
  4. Need to build a Web application using multiple Web projects 需要使用多个Web项目构建Web应用程序
  5. Need to add pre-build and post-build steps during compilation 需要在编译期间添加预构建和后构建步骤

Use Websites if you: 如果您:使用网站:

  1. Need to generate one assembly for each page. 需要为每个页面生成一个程序集。
  2. Prefer single-page code model to code-behind model. 首选单页代码模型到代码隐藏模型。
  3. Prefer dynamic compilation and working on pages without building entire site on each page view (that is, save file and then simply refresh the page in the browser). 首选动态编译和处理页面而不在每个页面视图上构建整个站点(即保存文件,然后只需在浏览器中刷新页面)。
  4. Want to open and edit any directory as a Web project without creating a project file 想要在不创建项目文件的情况下打开和编辑任何目录作为Web项目

@Mehrdad's link here is essential if you want to know more 如果您想了解更多信息,@ Mehrdad的链接至关重要 http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5 http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5

As for which project to choose, I would go with the Web Application Project, regardless of size. 至于选择哪个项目,无论大小如何,我都会使用Web应用程序项目。 Having all of your code behind compile down into a single DLL is a major benefit for maintenance and security on the hosting end. 将所有代码编译成单个DLL是托管端维护和安全性的主要好处。 I know there are precompile options for web site projects, but they seemed like more trouble that it was worth for me. 我知道网站项目有预编译选项,但它们对我来说似乎更麻烦。

I know that the IIS filters are in place to prevent users from accessing your .vb or .cs files, but it still makes me a little leery. 我知道IIS过滤器已经到位,以防止用户访问您的.vb或.cs文件,但它仍然让我有点怀疑。

But more important to this is the nice fact that if you make a bunch of coding changes, or maybe add some classes and change the processing logic, the only thing you have to merge up is the compiled DLL and nothing else. 但更重要的是,如果你进行一堆编码更改,或者可能添加一些类并更改处理逻辑,那么你必须合并的唯一东西就是编译后的DLL而不是别的东西。 Similarly, if you do a few UI changes (say change the stylesheet or position of a few controls), you don't have to worry about recompiling the application, you simply bring over the update .aspx page and you're done. 同样,如果你做了一些UI更改(比如更改样式表或几个控件的位置),你不必担心重新编译应用程序,只需将更新.aspx页面移除即可完成。

I'm used to create websites when I want to create a new webapplication. 当我想创建一个新的web应用程序时,我习惯于创建网站。

My current project had some problems on compiling, so I switched to a webapplication project. 我当前的项目在编译时遇到了一些问题,所以我切换到了一个webapplication项目。 The step isn't very hard. 这一步不是很难。 Visual Studio helps you to change all necessary lines. Visual Studio可帮助您更改所有必需的行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM