简体   繁体   English

为ASP.NET / ASP.NET MVC 3配置IIS(Windows 7)

[英]Configuring IIS (Windows 7) for ASP.NET / ASP.NET MVC 3

I am busy working with an ASP.NET MVC 3 application and using Windows 7. Currently it uses the built in web server to run the web application. 我正忙着使用ASP.NET MVC 3应用程序并使用Windows 7.目前它使用内置的Web服务器来运行Web应用程序。 I would like it to run in IIS. 我希望它在IIS中运行。 Is there any advice that I need to know about when setting this up to run on IIS? 在将此设置为在IIS上运行时,是否需要了解任何建议?

A guy from work said that my web application MUST be in the wwwroot directory for IIS to work properly. 一个工作的人说我的Web应用程序必须在wwwroot目录中,以便IIS正常工作。 My understanding of this is that if I created a virtual directory (web application can then be in any directory) then I should be ok? 我对此的理解是,如果我创建了一个虚拟目录(Web应用程序可以在任何目录中)那么我应该没问题?

Also, are there decent books that I can purchase that can help me in understanding IIS better? 另外,我可以购买哪些体面的书籍可以帮助我更好地理解IIS吗? This does not have to be specific to ASP.NET MVC. 这不一定是ASP.NET MVC特有的。 The only thing that I know how to do in IIS is to create a virtual directory :) 我知道在IIS中唯一能做的就是创建一个虚拟目录:)

How would I then debug the application when it is running in IIS? 如何在IIS中运行应用程序时调试应用程序?

Any advice and internet articles would be appreciated :) 任何建议和互联网文章将不胜感激:)

You can use VS.NET do to the work for you. 你可以使用VS.NET来为你工作。 In your project's properties page, switch to the "Web" tab and slect "Use Local IIS Web Server". 在项目的属性页面中,切换到“Web”选项卡并选择“使用本地IIS Web服务器”。 Provide the url you desire and VS. 提供你想要的网址和VS. will do the rest. 将完成剩下的工作。

To answer your question specifically, no your site doesn't have to be a sub folder of IIS's root folder for this to work and debugging will work as normal. 要专门回答您的问题,不要将您的站点作为IIS根文件夹的子文件夹,以使其工作,并且调试将正常工作。

FYI: I don't ever use the Development web server and have always used IIS. 仅供参考:我从未使用过开发网络服务器并且一直使用IIS。 Most of my project are sub folders of IIS's root folder and I manually edit the .proj file to point it to the right place. 我的大部分项目都是IIS根文件夹的子文件夹,我手动编辑.proj文件以将其指向正确的位置。 But this is not required for things to work. 但这不是工作所必需的。

With Internet Information Services Manager you should be able to do a lot more than create virtual folders. 使用Internet Information Services Manager,您应该能够创建比创建虚拟文件夹更多的功能。 Things are quite a bit simpler. 事情变得更加简单。

However, as regards IIS and ASP.NET in general. 但是,关于IIS和ASP.NET一般。 I'd suggest you read up on App Pools and their process model (the various options under ProcessModel as well as other sections). 我建议您阅读App Pools及其流程模型(ProcessModel以及其他部分下的各种选项)。

MSDN and http://www.iis.net/ are generally good places to get decent information on all things IIS. MSDN和http://www.iis.net/通常是获取有关IIS所有内容的正确信息的好地方。

Edit: As an aside, you may also want to look at the recently introduced IIS Express. 编辑:另外,您可能还想查看最近推出的IIS Express。 It actually replaces the development server and is really IIS 7 for all intents and purposes so all of IIS 7's functionality is available. 它实际上取代了开发服务器,并且实际上是IIS 7用于所有意图和目的,因此IIS 7的所有功能都可用。 Plus you don't need to run your VS as administrator if for some reason you're not able to. 另外,如果由于某种原因你不能以管理员的身份运行你的VS.

If you are able to run VS.NET as administrator on your machine I'd suggest using IIS 7. 如果您能够在计算机上以管理员身份运行VS.NET,我建议使用IIS 7。

You might want to check the following article on deploying ASP.Net MVC applications under IIS: 您可能需要查看以下有关在IIS下部署ASP.Net MVC应用程序的文章:

Normally deploying an ASP.Net MVC application under IIS7 is very similar to deploying a standard ASP.Net application with the additional requirement of a rew MVC runtime assemblies. 通常在IIS7下部署ASP.Net MVC应用程序非常类似于部署标准ASP.Net应用程序以及重新安装MVC运行时程序集的附加要求。

To answer some of your other questinons: 要回答你的一些其他任务:

  • Does my application to be in the wwwroot directory for IIS to work properly? 我的应用程序是否在wwwroot目录中以便IIS正常工作?

Nope, this is incorrect - you can use a virtual directory if your application is not located in the wwwroot directory. 不,这是不正确的 - 如果您的应用程序不在wwwroot目录中,您可以使用虚拟目录。

  • How do I debug my application when it is running in IIS? 如何在IIS中运行应用程序时调试我的应用程序?

You need to attach to the w3wp.exe process using Visual Studio using the "Debug" -> "Attach to process..." command - once you are attached the debugging experience should be similar to when you start the application using F5. 您需要使用Visual Studio使用“调试” - >“附加到进程...”命令附加到w3wp.exe进程 - 一旦连接,调试体验应与使用F5启动应用程序时类似。

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

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