Skip to content
Donner's Daily Dose of Drama
Donner's Daily Dose of Drama
  • The Good
    • Blogging
    • Consumer Protection
    • Environment
    • Ethics
    • Geek’s Home
    • Lisa Lanett
    • Medfield
    • Music
    • Parenting and Technology
    • Travel
    • wow
  • The Bad
    • Business
    • Ebay
    • Investment
    • Job search
    • Personal Finance
    • Politics
  • The Ugly
    • Information Technology
      • Business Intelligence
      • Content Management
      • Free Software
      • I18N and L10N
      • Java
      • Open Source
      • Mobile Devices
      • Open Source Business Intelligence
      • OSBI
      • SDA
      • Security
      • Smartphone
      • Software Best Practices
      • Software Engineering
      • SQL Server
      • Streaming Media
      • Web
    • Austria
    • Fiction
    • Hardware
    • iPod
    • Miscellaneous
    • Uncategorized
    • Video
    • Weekend Warrior
Donner's Daily Dose of Drama

MVC 5 on Windows Server 2008/IIS 7

Christian Donner, December 27, 2013September 17, 2015

I have been working on a small Website built with Visual Studio 2013, .Net 4.5, Entity Framework (code-first), and MVC 5. I started out with the MVC template for responsive sites that includes Bootstrap. Everything went smoothly until I deployed the site to our QA server.

This box runs Windows Server 2008 x64 (no, not R2). I naively published my app to a local folder and copied everything to the server folder that I created for the new website. After I updated the connection string in the web.config and started the site, I got the ominous

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

when I tried to hit the home page. Little did I know that it would take me the next 6 hours to figure out what was going on. Because I had to once again sift through so much misinformation on the web about this issue, I am going to write up what I found.

IIS Configuration

Common things to check when a website does not run properly are

  • The app pool configuration
    • pipeline mode
    • target .Net framework (4.0.30319 is the latest, and 4.5.1 is installed)
    • credentials
  • Folder security (allow access for the app pool user)
  • Website security (anonymous access is needed for my site)
  • Re-register ASP.Net by running aspnet_regiis ad nauseam

None of these things applied, though, because I had done a thorough job installing .Net 4.5.1 and configuring my site.

Deployment Method

Because IIS seemed to be set up and configured correctly for my website, I looked at the way I deployed. Maybe something was missing?

I installed the Web Platform Installer on our server and added the Web Deploy plugin (3.5). This is required if you want to either use the one-click deployment from Visual Studio or use the Web Deployment Package script that Visual Studio generates. I removed my website from the server, recreated it from scratch, and tried both deployment methods in Visual Studio with the same results.

From the error message it appears that MVC is not working properly. IIS is looking for a default page to load, does not find one in the root of an MVC site, and can’t show the folder content because folder browsing is disabled. But why? Clearly this has to do with the way requests are routed to the correct module in IIS, and somewhere this process is broken.

There are dozens of questions on Stackoverflow related to this issue with answers all over the map, some trivial, some complex. I came back to the same recommendation, though, because nothing else seemed to apply: adding these lines to the web.config:

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

There are valid concerns about implementing such a drastic measure, though, for example by Rick Strahl or by this chap. I tried to add this manually to my web.config, but only got an error. My IIS did not understand the <system.webServer> section, even though I followed the documentation closely.
None of the hot fixes that were referenced in these posts worked for me (for example this one or this one), presumably because I am on Server 2008 and not R2, and when I tried to install, I would only get the message that the hotfix does not apply to my server. And by the way, the server is current with patches, so any hotfixes would have been applied in the past anyway.

Managed Modules

The bin folder contained all the necessary assemblies for MVC (MVC 5 does not need to be deployed as a prerequisite because it is part of the web site deployment package).

And yet, for some reason, MVC did not rewrite the URL to invoke the correct handlers for my site. So, after more poking around in various Stackoverflow articles and blog posts I had a break-through when I finally came across this one on MSDN. It explains how to use the IIS Manager’s GUI to explicitly add the UrlRoutingModule to the web.config, even though it showed up as installed for my site:

UrlRoutingModule 4.0
UrlRoutingModule 4.0

After I unchecked the “Invoke only for requests to ASP.NET applications or managed handlers” checkbox the Entry Type changed to Local (see the screen shot above) and a corresponding section appeared in my web.config. IIS suddenly began to understand <system.webServer> section (I still don’t know why), and the site started to render MVC views.

The section that was added, btw, is this one:

&#60;system .webServer&#62;
&#60;modules&#62;
&#60;remove name="UrlRoutingModule-4.0"&#62;&#60;/remove&#62;
&#60;add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition=""&#62;&#60;/add&#62;
&#60;/modules&#62;
&#60;/system&#62;

I had seen this before at this point, but only now it made sense to me. What still does not make sense to me is why this was necessary and why
a. Visual Studio had not included this in the web.config
b. The routing module was not invoked without this setting.

Related Posts:

  • OpenVPN
  • The Voip.ms SMS Integration for Home Assistant
  • My USPS Certified Mail Experience Explained
  • Amazon threatens customer of 26 years
  • Enphase Envoy Local Access
Web .Net 4.5IIS 7ModulesMVC 4RoutingWindows Server 2008

Post navigation

Previous post
Next post

Comments (34)

  1. Chris says:
    February 15, 2014 at 3:50 am

    Thanks for taking the time to document – exactly my problem.

  2. Scott says:
    March 21, 2014 at 7:05 am

    Huge thanks for posting this. Saved me.

  3. Stef says:
    April 1, 2014 at 11:15 am

    Another thanks here – saved hours – and my blood pressure !

  4. Vadim says:
    April 30, 2014 at 6:18 am

    Thanks a lot. Great useful post.

  5. Christian says:
    May 4, 2014 at 9:37 am

    Thank you so much! You saved me 6 hours of misinformation.

  6. Dirk says:
    May 12, 2014 at 5:00 am

    Thank you thank you thank you thank you

  7. Flávio says:
    May 13, 2014 at 9:43 am

    Congratulations for you, I suffered much time because this problem and only now, after read your post, it was solved.

  8. Manuel says:
    May 22, 2014 at 9:35 am

    Thank you so very much! Individuals with your spirit make peoples’ lives better!

  9. Ryan says:
    July 14, 2014 at 1:29 pm

    Thanks so much. I wasted 3 hours, but you saved me the other 3 🙂

    /cheers

  10. Anthony Nguyen says:
    July 15, 2014 at 8:06 am

    Thanks, I wasted a day with this problem. You saved my life. My boss can’t cut off my head:)

  11. Ian Yates says:
    October 14, 2014 at 3:00 am

    Thanks for sharing this. Massive help!! 🙂

  12. Frounz says:
    October 15, 2014 at 1:10 am

    Thank you VERY MUCH ! solved my problem perfectly ! 🙂

  13. Leonel Sarmiento says:
    October 21, 2014 at 8:10 pm

    Thank you very much! I wasted 1 week for this, but you save my other weeks. 😀

  14. Very Appreciative Web Dev says:
    October 27, 2014 at 2:30 pm

    This is the most informative and useful post on how to get MVC working on IIS. Your problem was exactly my problem and you were the only one who had the answer. Thank you so much.

  15. shay says:
    October 28, 2014 at 8:23 pm

    Thank you so much I had gone through all the same steps to debug the routing issue and your post saved me from despair.

  16. darius says:
    November 10, 2014 at 10:24 am

    Wow, just wow. I had trouble finding ‘modules’ 🙂 haha, but insisted on searching it, until i’ve found it, and it works, brilliant.

  17. peterb says:
    November 10, 2014 at 11:36 pm

    I am trying out a small MVC5 application on Windows 2008 R2 and having the same http error 403.14.
    I have carefully read your blog and unchecked the changes in urlrouting module entry .
    I have used the .NET4.5 to buld my application but trying to run it in the .NET 4.0 application pool.
    I have no idea where to start diagnosing this proble.

  18. Dairy Milk says:
    February 23, 2015 at 7:43 am

    Thanks you very much

    I followed the instructions you mentioned and it worked for me. Saved me hours.

    I did a google search for “deploy asp.net mvc 5 to iis 7” and the answer (link to your site) was 7th in the google search

    Best Regards
    DairyMilk

  19. Sandeep Beniwal says:
    March 10, 2015 at 8:22 am

    Thanks bro.

    You made my day. Suffering from last two days because of this problem.

    Thanks a lot.

  20. Doug says:
    March 10, 2015 at 1:16 pm

    After 10 hours we finally made a small change and, instead of 404 errors, the system started giving us 403.14’s, leading us right to your blog. Five minutes later we were up and running. Thanks so much!

  21. Mauricio F says:
    July 31, 2015 at 1:57 pm

    Muchas gracias, la unica web con una solución rápida y decente.

  22. Mauricio Bedoya says:
    December 26, 2015 at 5:41 pm

    Awesome! Saved my day!, Really did.

    Thanks Buddy

  23. orney says:
    May 25, 2016 at 12:37 pm

    Thanks very much. It was wath happen to my site…

  24. itasco says:
    July 8, 2016 at 2:59 pm

    Thanks man. This helped us twice already 🙂

  25. Marcelo Santos says:
    August 1, 2016 at 10:58 am

    Thanks you my friend, this article solve my problems. I was already working a week ago in my Web.config settings whitout sucess.

  26. Tran Minh Xuan says:
    September 8, 2016 at 5:45 am

    Thanks a lot. But I have some issue after run.
    MVC 5 with bundles css, js not working.
    I thinks if have condition, upgrade to windows server 2012.

  27. Tran Minh Xuan says:
    September 8, 2016 at 6:04 am

    If error on css, jquery. Fix asap use publish choose Debug. Because release will use bundles and iis 7.5 not understand

  28. lordzam says:
    September 22, 2016 at 5:50 am

    Thanks bro, Great post!

  29. Chet Creacy says:
    November 3, 2016 at 10:54 am

    Big thanks for posting this fix! Saved me a lot of wasted hours.

  30. Ryan says:
    November 21, 2016 at 12:19 pm

    I almost gave up after hours of stackoverflow searching, but this post saved the day!
    Thanks a lot!

  31. Anuja says:
    December 20, 2016 at 12:25 am

    Thank you very much.
    This is really helpful……..

  32. Warren says:
    December 21, 2016 at 8:31 pm

    One question – you keep saying “in my web.config”. The web.config where? Of your specific web application? How would just doing something within the IIS mgr gui modify the web.config file of a particular web application? Can you clarify that please.

  33. Christian Donner says:
    December 21, 2016 at 9:27 pm

    Warren, many site configuration changes are persisted in the web.config for the site. Certain things are persisted in other, system-wide configuration files (bindings, for example), but in this case they were not.

  34. Muhammad Maqbool says:
    January 18, 2017 at 3:52 am

    it worked for me, great help thanks a lot…..

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About
  • Awards
    • TechnoLawyer
  • Contact Christian Donner
  • Project Portfolio
  • Publications
  • Speaking Engagements

Recent Comments

  • Christian Donner on Sealing a leaky cast-iron fireplace chimney damper
  • Eric on Sealing a leaky cast-iron fireplace chimney damper
  • Christian Donner on Contact Christian Donner
  • Max on Contact Christian Donner
  • Christian Donner on Contact Christian Donner

Tags

AHCI Amazon Android ASP.Net AT&T Droid Drupal email Error failure featured firmware Garmin Godaddy Google honda Internet Explorer 8 iPhone Lenovo Lisa Lanett Modules NAS Nexus One Paypal Performance Privacy QNAP raid RS-407 sauna Security spam SQL SR3600 Synology T-Mobile T430s transmission tylö Verizon Virus VMWare Windows 7 windows 8.1 Windows Mobile
  • About
  • Awards
    • TechnoLawyer
  • Contact Christian Donner
  • Project Portfolio
  • Publications
  • Speaking Engagements
©2025 Donner's Daily Dose of Drama | WordPress Theme by SuperbThemes