简体   繁体   中英

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. I would like it to run in IIS. Is there any advice that I need to know about when setting this up to run on IIS?

A guy from work said that my web application MUST be in the wwwroot directory for IIS to work properly. 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?

Also, are there decent books that I can purchase that can help me in understanding IIS better? This does not have to be specific to ASP.NET MVC. The only thing that I know how to do in IIS is to create a virtual directory :)

How would I then debug the application when it is running in IIS?

Any advice and internet articles would be appreciated :)

You can use VS.NET do to the work for you. In your project's properties page, switch to the "Web" tab and slect "Use Local IIS Web Server". Provide the url you desire and 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.

FYI: I don't ever use the Development web server and have always used 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. 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. Things are quite a bit simpler.

However, as regards IIS and ASP.NET in general. I'd suggest you read up on App Pools and their process model (the various options under ProcessModel as well as other sections).

MSDN and http://www.iis.net/ are generally good places to get decent information on all things IIS.

Edit: As an aside, you may also want to look at the recently introduced 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. Plus you don't need to run your VS as administrator if for some reason you're not able to.

If you are able to run VS.NET as administrator on your machine I'd suggest using IIS 7.

You might want to check the following article on deploying ASP.Net MVC applications under IIS:

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.

To answer some of your other questinons:

  • Does my application to be in the wwwroot directory for IIS to work properly?

Nope, this is incorrect - you can use a virtual directory if your application is not located in the wwwroot directory.

  • How do I debug my application when it is running in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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