Can't run ASP.NET MVC 2 web app on IIS 7.5

Visual Studio-2010Visual StudioIisasp.net Mvc-2Iis 7.5

Visual Studio-2010 Problem Overview


I'm trying to run an ASP.NET MVC 2 web application under IIS on Windows 7, but I get a 403.14 error. Here are the steps to reproduce:

  1. Open Visual Studio 2010
  2. Create a new ASP.NET MVC 2 project called MvcApplication1
  3. Shift+F5 to run the app. You should see http://localhost:{random_port}/ and the page will render correctly.
  4. Click on MvcApplication1, and select "Properties". Go to the "Web" section.
  5. Select "Use Local IIS Web server" and create a virtual directory.
  6. Save.
  7. Shift+F5 to run the app. You should see http://localhost/MvcApplication1/ and an IIS error HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory..

It's clear that for whatever reason, ASP.NET routing is not working correctly.

Things I've already thought of and tried:

  • Verified that all IIS features are enabled in "Turn Windows features on or off".
  • Verified that the default website is configured to use .NET 4.0
  • Reassigned ASP.NET v4 scripmaps via aspnet_regiis -i in the v4.0.30319 directory.

Here's the most amazing part - this is on a just-built machine. New copy of Windows 7 x64 Ultimate, clean install of Visual Studio 2010 Premium, no other websites and no other work performed.

Anything else I can try?

Setting Visual Studio to use local IIS web server

Visual Studio-2010 Solutions


Solution 1 - Visual Studio-2010

Ok, this is resolved for me, by doing the following:

Running aspnet_regiis -i in the 32-bit directory c:\Windows\Microsoft.NET\Framework\v4.0.30319.

At this point, I don't understand why 64-bit mode isn't working, but I'm now unblocked. Hopefully this helps anyone else who is having this issue.

Solution 2 - Visual Studio-2010

I had exactly the same issue, so thanks for your help.

However... did you try running the aspnet_regiis -i command in the Visual Studio 64 bit command prompt (with admin privileges)? When I did that it fixed it for the 64-bit mode.

To clarify, I right clicked on Visual Studio x64 Win64 Command Prompt (2010) and chose Run as Administrator. Then I went here:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

And did this: aspnet_regiis -i

And now it works perfectly.

Solution 3 - Visual Studio-2010

Also ensure that you configuration file has the following line otherwise the routing will not work.

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Solution 4 - Visual Studio-2010

Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Instead add the MVC routing module

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>

Solution 5 - Visual Studio-2010

Another thing to note, make sure your application pool is set to integrated, not classic

Solution 6 - Visual Studio-2010

I had this same problem on IIS8 / Windows Server 2012. None of the many proposed solutions worked until I tried the following.

dism /online /enable-feature /featurename:IIS-ASPNET45 /All

Without the '/All' switch it complained that a parent feature was not installed.

The strange thing is that according to Windows' Turn Windows Features on or off facility, asp.net 4.5 was already installed.

There was no need to make any changes to the web.config, add or remove modules.

Solution 7 - Visual Studio-2010

I've always used the custom server setting in VS 2008, which still allows me to debug with no problems. Not sure if it works any differently in 2010

Solution 8 - Visual Studio-2010

I had these symptoms; My Global.asax was crashing. Fixed the crash, everything is working now.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPortmanView Question on Stackoverflow
Solution 1 - Visual Studio-2010PortmanView Answer on Stackoverflow
Solution 2 - Visual Studio-2010Tom ChantlerView Answer on Stackoverflow
Solution 3 - Visual Studio-2010Rohan WestView Answer on Stackoverflow
Solution 4 - Visual Studio-2010Chris HerringView Answer on Stackoverflow
Solution 5 - Visual Studio-2010JGilmartinView Answer on Stackoverflow
Solution 6 - Visual Studio-2010Jeroen RitmeijerView Answer on Stackoverflow
Solution 7 - Visual Studio-2010Daniel SchafferView Answer on Stackoverflow
Solution 8 - Visual Studio-2010CharlieView Answer on Stackoverflow