visual-studio ASP.NET 网站或 Web 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:21:47  来源:igfitidea点击:

ASP.NET Web Site or Web Project

asp.netvisual-studioweb-site-projectweb-application-project

提问by jdiaz

When creating a new ASP.NET project in Visual Studio should I chose create: website or project?

在 Visual Studio 中创建新的 ASP.NET 项目时,我应该选择创建:网站还是项目?

I understand that web application project was the way to do it back in the day with VS 2003 but is it still applicable today? What are some of the caveats using one over the other?

我知道 Web 应用程序项目是使用 VS 2003 实现的方式,但它今天仍然适用吗?使用一个而不是另一个有哪些注意事项?

回答by Jon Galloway

There's a pretty good comparison chart on MSDN.

MSDN 上有一个很好的比较图表

Website projects are simple, in that all files added to the project folders are automatically compiled and included, which was supposedly added to make it more palatable to classic ASP and PHP developers. Once benefit is that it includes build providers, which allow for certain actions to be associated with a filetype - that's how the first release of SubSonic would rebuild the data access layer when you added a .abp file to the site.

网站项目很简单,因为添加到项目文件夹中的所有文件都会自动编译并包含在内,据说添加这些文件是为了使其更适合经典的 ASP 和 PHP 开发人员。一个好处是它包括构建提供程序,它允许将某些操作与文件类型相关联 - 这就是当您向站点添加 .abp 文件时 SubSonic 的第一个版本将重建数据访问层的方式。

Web Application Projects are a lot more flexible, though. For instance, all class libraries in a Website Project need to be in the App_Code folder, which is frustrating in a complex application. There are a lot of scenarios which just don't work for a Website Project.

不过,Web 应用程序项目要灵活得多。例如,网站项目中的所有类库都需要在 App_Code 文件夹中,这在复杂的应用程序中令人沮丧。有很多场景不适用于网站项目。

You can convert from one to another, although if you're unsure I'd recommend just starting with a Web Application.

您可以从一个转换为另一个,但如果您不确定,我建议您从 Web 应用程序开始。

回答by John Saunders

I strongly disagree with some of what the Websites and Web Projectsarticle says.

我强烈不同意网站和 Web 项目文章中的一些内容。

First, it wasn't any "small" group of developers who rebelled - I'd suggest it was most of us, who had not been asked if we wanted to totally change the way we developed. They certainly didn't ask me if I wanted to lose six weeks of development time figuring out what they did to break a perfectly good web service.

首先,不是任何“小”开发者群体反抗——我认为是我们中的大多数人,他们没有被问到我们是否想要完全改变我们的开发方式。他们当然没有问我是否想浪费六周的开发时间来弄清楚他们做了什么来破坏完美的 Web 服务。

It wasn't some "download" MS released - it was VS2005 SP1, and they released it pretty damned fast.

这不是发布的一些“下载”MS——它是VS2005 SP1,而且他们发布的速度非常快。

In their plusses for projectless development, the "Copy Project" command works very well, and we don't have to avoid debug or project files; you can move pages around - if you don't use source control; where do they get that you have to lock the project files in order to collaborate? What are they using for source control?

在无项目开发方面的优势中,“复制项目”命令非常有效,我们不必避免调试或项目文件;您可以四处移动页面 - 如果您不使用源代码管理;他们从哪里得知您必须锁定项目文件才能进行协作?他们使用什么进行源代码控制?

I'd also add one question to the debate: what's so special about web sites that they should be the only "project" type (as far as I know) that doesn't use a "project" file? I can't think of anything, unless it's that Microsoft thought that web developers were too simpleminded to understand projects.

我还要在辩论中添加一个问题:网站有什么特别之处以至于它们应该是唯一不使用“项目”文件的“项目”类型(据我所知)?我想不出什么,除非是微软认为 Web 开发人员头脑太简单,无法理解项目。

Of course, if anyone knows of any other Visual Studio "project" type that does not use a project file, I'd be grateful to be informed of it.

当然,如果有人知道不使用项目文件的任何其他 Visual Studio“项目”类型,我将不胜感激。