ASP.NET 网站还是 ASP.NET Web 应用程序? [英] ASP.NET Web Site or ASP.NET Web Application?

查看:42
本文介绍了ASP.NET 网站还是 ASP.NET Web 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Visual Studio 中开始一个新的 ASP.NET 项目时,我可以创建一个 ASP.NET Web 应用程序或者我可以创建一个 ASP.NET 网站.

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.

ASP.NET Web 应用程序和 ASP.NET 网站有什么区别?我为什么要选择其中之一?

What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other?

答案是否因我使用的 Visual Studio 版本而异?

Is the answer different based on which version of Visual Studio I am using?

推荐答案

网址:

网站 项目是即时编译的.你最终会得到更多的 DLL 文件,这可能会很痛苦.当一个目录中的页面或控件需要引用另一个目录中的页面和控件时,它也会出现问题,因为另一个目录可能尚未编译到代码中.另一个问题可能是发布.

Website:

The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into the code yet. Another problem can be in publishing.

如果 Visual Studio 没有被告知不断重复使用相同的名称,它会一直为页面生成的 DLL 文件提供新名称.这可能导致多个包含相同类名的 DLL 文件的紧密副本,这将产生大量错误.Web Site 项目是在 Visual Studio 2005 中引入的,但结果证明它并不流行.

If Visual Studio isn't told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be popular.

Web 应用程序 项目是作为插件创建的,现在作为一部分存在适用于 Visual Studio 2005 的 SP 1.主要区别在于 Web 应用程序项目旨在与 Visual Studio 2003 附带的 Web 项目类似地工作.它将在构建时将应用程序编译为单个 DLL 文件时间.要更新项目,必须重新编译它和 DLL 文件发布以便发生更改.

The Web Application Project was created as an add-in and now exists as part of SP 1 for Visual Studio 2005. The main differences are the Web Application Project was designed to work similarly to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time. To update the project, it must be recompiled and the DLL file published for changes to occur.

Web 应用程序的另一个不错的功能project 从项目视图中排除文件要容易得多.在里面网站项目,您排除的每个文件都被重命名为排除的文件名中的关键字.在 Web Application Project 中,该项目只是跟踪要从项目视图中包含/排除的文件,而不需要重命名它们,让事情变得更整洁.

Another nice feature of the Web Application project is it's much easier to exclude files from the project view. In the Web Site project, each file that you exclude is renamed with an excluded keyword in the filename. In the Web Application Project, the project just keeps track of which files to include/exclude from the project view without renaming them, making things much tidier.

参考

文章ASP.NET 2.0 - 网站与 Web 应用程序项目 还给出了为什么使用一个而不是另一个的原因.摘录如下:

The article ASP.NET 2.0 - Web Site vs Web Application project also gives reasons on why to use one and not the other. Here is an excerpt of it:

  • 您需要将大型 Visual Studio .NET 2003 应用程序迁移到 VS2005年?使用 Web 应用程序项目.
  • 您想打开和编辑任何目录作为 Web 项目而不需要创建项目文件?使用网站项目.
  • 您需要在编译期间添加预构建和后构建步骤吗?使用 Web 应用程序项目.
  • 您需要使用多个 Web 构建一个 Web 应用程序项目?使用 Web 应用程序项目.
  • 您想为每一页生成一个程序集吗?使用网站项目.
  • 您更喜欢动态编译和在不构建的情况下处理页面每个页面查看整个网站?使用网络网站项目.
  • 与代码隐藏模型相比,您更喜欢单页代码模型吗?使用网站项目.

Web 应用程序项目与网站项目em> (MSDN) 解释了网站和 Web 应用程序项目之间的区别.此外,它还讨论了要在 Visual Studio 中进行的配置.

Web Application Projects versus Web Site Projects (MSDN) explains the differences between the web site and web application projects. Also, it discusses the configuration to be made in Visual Studio.

这篇关于ASP.NET 网站还是 ASP.NET Web 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆