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

55,651

Solution 1

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.

Solution 2

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.

Share:
55,651
Brendan Vogt
Author by

Brendan Vogt

Wedding photographer and videographer from Paarl, South Africa. Join me on my new adventure in wedding photography and videography at Brendan Vogt Photo & Video.

Updated on August 28, 2020

Comments

  • Brendan Vogt
    Brendan Vogt over 3 years

    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 :)

  • Brendan Vogt
    Brendan Vogt about 13 years
    Thanks. How would I use debugging the web application in IIS?
  • Shiv Kumar
    Shiv Kumar about 13 years
    As I said debugging works as normal. hit the F5 key in VS and off you go. No change. The difference you'll notice is that things actually move faster and since you'll be deploying to IIS (your production server) there won't be situations where is work on my dev box but... Or cases where somethings just can't be done using the development server.
  • Shiv Kumar
    Shiv Kumar about 13 years
    there is no need to do a attach to process etc. Simply hit the F5 key to debug any ASP.NET application. Also, you may want to edit your answer about "ASP.NET MVC applications work just fine". That implies that other ASP.NET applications don't :). Just so it's clear to someone else that has a similar question.
  • Justin
    Justin about 13 years
    @Shiv Thanks - I thought the w3wp.exe information was worth including for people not using the deploy to IIS option - under Windows 7 using deploy to IIS means that you need to run VS as an administrator, which is a bit of a pain.
  • Shiv Kumar
    Shiv Kumar about 13 years
    Hmm... Maybe that's an issue with VS.NET 2008 and earlier (I forget if VS.NET 2008 has this issue)? I don't run VS.NET 2010 as administrator. I am an administrator on the box but I don't run as administrator. I do remember having to do with with VS.NET 2005. But really, simply right click on the VS shortcut, and choose properties and in one of the tabs shown in the dialog, check the Run as administrator check box. Anyone doing serious web development needs the rights to to do this :)
  • Shiv Kumar
    Shiv Kumar about 13 years
    Attach to process is ok/good if you're deep in some part of the system and you don't want to start from the log in page and navigate all the way to a page 4-10 steps in.