Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

asp.net - ASP.NET网站还是ASP.NET Web应用程序?(ASP.NET Web Site or ASP.NET Web Application?)

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.

(当我在Visual Studio中启动新的ASP.NET项目时,可以创建一个ASP.NET Web应用程序,也可以创建一个ASP.NET网站。)

What is the difference between ASP.NET Web Application and ASP.NET Web Site?

(ASP.NET Web应用程序和ASP.NET网站之间有什么区别?)

Why would I choose one over other?

(我为什么要选择一个?)

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

(根据我使用的Visual Studio版本,答案是否有所不同?)

  ask by Robert S. translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Website:

(网站:)

The Web Site project is compiled on the fly.

(网站项目是即时编译的。)

You end up with a lot more DLL files, which can be a pain.

(您最终将获得更多的DLL文件,这可能很痛苦。)

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.

(另一个问题可能在发布中。)

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.

(如果不要求Visual Studio不断重复使用相同的名称,它将为页面始终生成的DLL文件提供新的名称。)

That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors.

(这可能会导致包含相同类名的DLL文件的多个紧密副本,这将产生大量错误。)

The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be extremely popular.

(该Web站点项目是随Visual Studio 2005一起引入的,但事实证明它并不是很受欢迎。)

Web Application:

(Web应用程序:)

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 similar to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time.

(Web应用程序项目是作为外接程序创建的,现在作为Visual Studio 2005 SP 1的一部分存在。主要区别在于Web应用程序项目的设计工作原理与Visual Studio 2003附带的Web项目类似。在构建时将应用程序编译为单个DLL文件。)

In order to update the project, it must be recompiled and the DLL file published for changes to occur.

(为了更新项目,必须对其进行重新编译并发布DLL文件以进行更改。)

Another nice feature of the Web Application project is it's much easier to exclude files from the project view.

(Web应用程序项目的另一个不错的功能是,从项目视图中排除文件要容易得多。)

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.

(在Web应用程序项目中,该项目只是跟踪要从项目视图中包含/排除的文件,而无需重命名它们,从而使事情变得更加整洁。)

Reference

(参考)

The article ASP.NET 2.0 - Web Site vs Web Application project also gives reasons on why to use one and not the other.

(“ ASP.NET 2.0-网站与Web应用程序”项目一文也提供了为什么使用一个而不使用另一个的原因。)

Here is an excerpt of it:

(这是它的摘录:)

  • You need to migrate large Visual Studio .NET 2003 applications to VS 2005?

    (您需要将大型Visual Studio .NET 2003应用程序迁移到VS 2005吗?)

    use the Web Application project.

    (使用Web应用程序项目。)

  • You want to open and edit any directory as a Web project without creating a project file?

    (您要在不创建项目文件的情况下作为Web项目打开和编辑任何目录吗?)

    use Web Site project.

    (使用网站项目。)

  • You need to add pre-build and post-build steps during compilation?

    (您需要在编译期间添加构建前和构建后步骤吗?)

    use Web Application project.

    (使用Web应用程序项目。)

  • You need to build a Web application using multiple Web projects?

    (您需要使用多个Web项目来构建Web应用程序吗?)

    use Web Application project.

    (使用Web应用程序项目。)

  • You want to generate one assembly for each page?

    (您要为每个页面生成一个程序集吗?)

    use Web Site project.

    (使用网站项目。)

  • You prefer dynamic compilation and working on pages without building entire site on each page view?

    (您希望动态编译和处理页面而不在每个页面视图上构建整个网站?)

    use Web Site project.

    (使用网站项目。)

  • You prefer single-page code model to code-behind model?

    (您更喜欢单页代码模型而不是代码隐藏模型?)

    use Web Site project.

    (使用网站项目。)

Web Application Projects versus Web Site Projects (MSDN) explains the differences between the web site and web application projects.

(Web应用程序项目与Web站点项目 (MSDN)解释了Web站点和Web应用程序项目之间的区别。)

Also, it discusses the configuration to be made in Visual Studio.

(此外,它还讨论了要在Visual Studio中进行的配置。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...