338

I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently decided to have VS run/debug my apps on IIS rather than the dev server that comes with it.

However, every time I try to run an MVC app, I get the following error:

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

Error Information

Module DirectoryListingModule

Notification ExecuteRequestHandler

Handler StaticFile Error

Code 0x00000000 Requested

URL http://localhost:80/mySite/

Physical Path C:\myProject\mySite\

Logon Method Anonymous Logon

User Anonymous

I placed a default.aspx file in the directory and I received the following error:

HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Are there any other steps I forgot to take to get this working?

Notes: I installed IIS 7.5 after installing VS 2010 RC. I used the built-in "Create Virtual Directory" button under the "Web" tab in the MVC project's "Properties" in Visual Studio 2010. I made sure that the application is using the ASP.NET 4 App Pool.

Below are the installed features of IIS I have.

alt text

Omar
  • 37,391
  • 42
  • 132
  • 207
  • Okay, I have a similar problem and it shows up only with ASP.NET MVC 3 websites. ASP.NET MVC 2 websites work fine. I placed a Default.aspx file in the root of the website and it got picked up okay, no problem. I have bin-deployed the ASP.NET MVC 3 website using VS2010 SP1 and still no-joy. I am at my wits end with this. – Umar Farooq Khawaja Jun 11 '11 at 23:43
  • Did you make sure that the app pool for the MVC 3 app is set to .NET 4.0? – Omar Jun 11 '11 at 23:50
  • Yeah. It's set to 4.0/Integrated. I have also ran aspnet_regiis -ir. – Umar Farooq Khawaja Jun 12 '11 at 08:51
  • 5
    I am having this same issue. I have set the application to use 4.0 integrated, ran the registration command to register .NET with IIS (7.5) and still get this error. – Collin White Jun 14 '11 at 03:18
  • 2
    I was finally able to find the problem in my set up, which was that I had renamed the file `_Layout.cshtml` to `_PageLayout.cshtml` and had made the corresponding change in `_ViewStart.cshtml` as well, but apparently that was not enough. Once I reverted the name to `_Layout.cshtml`, it started working. What was confusing was that `_PageLayout.cshtml` was picked up correctly on Win7 32 bit but was not picked up on Win7 64 bit or WinSvr2K8 R2. – Umar Farooq Khawaja Jun 15 '11 at 09:19
  • Make sure that you run aspnet_regiis -i/aspnet_regiis -r as given below. For good measure, delete the existing website and app pool if you can and stop IIS before you run the commands. You should also make sure that you either install ASP.NET MVC 3 onto the server, or Bin Deploy. For doing that easily, you're gonna need VS2010 SP1. See my first answer to this question http://stackoverflow.com/questions/5601325/asp-net-mvc3-in-iis-7-5 for how to do that. – Umar Farooq Khawaja Jun 15 '11 at 09:23
  • 3
    Has anyone found a solution to this on Windows 8 with IIS 8? – Eric Z Beard Oct 01 '12 at 20:03
  • 3
    If you're on Windows Server 2012 or window 8 see this: [http://stackoverflow.com/questions/12134713/server-2012-iis-8-mvc-not-working][1] [1]: http://stackoverflow.com/questions/12134713/server-2012-iis-8-mvc-not-working – Lomak Apr 02 '13 at 09:33
  • Disable ASP.NET impersonation and it can fix the problem too – Greg Goldberg Jun 25 '13 at 04:06
  • I found I had to recreate my application in IIS to get it working too. – Ben Power Oct 24 '13 at 23:26

28 Answers28

499

ASP.NET 4 was not registered in IIS. Had to run the following command in the command line/run

32bit (x86) Windows

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

64bit (x64) Windows

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

Note from David Murdoch's comment:

That the .net version has changed since this Answer was posted. Check which version of the framework is in the %windir%\Microsoft.NET\Framework64 directory and change the command accordingly before running (it is currently v4.0.30319)

Omar
  • 37,391
  • 42
  • 132
  • 207
  • 9
    **Note the "64" in Framework64** for 64-bit Windows! that bit me in the *ss. I must've installed the 32 bit verion 4 or 5 times with no effect. – Ben Lesh Jan 04 '11 at 15:31
  • How do I use this command on hosting? I can't run applications on the hosting! – Alexandre Apr 18 '11 at 20:18
  • If you're on a shared host, you need to contact your provider to enable .NET 4 for you. – Omar Apr 18 '11 at 20:53
  • 14
    That the .net version has changed since this Answer was posted. __Check which version of the framework is in the `%windir%\Microsoft.NET\Framework64` directory and change the command accordingly before running (it is currently v4.0.30319).__ – David Murdoch Apr 21 '11 at 20:22
  • to legendo - mucim se vec sat vremena! :) – Senad Uka Feb 23 '12 at 13:53
  • 1
    to add to @blesh, if you have 64-bit and run the 32-bit aspnet_regiis.exe, it might just re-show you the options and do nothing – xster May 02 '12 at 20:28
  • 3
    If the aspnet_regiis.exe command is missing from the .net framework folder, download the full .net framework installer http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17851 – warrickh Jul 11 '12 at 14:39
  • 11
    This doesn't work in IIS8 btw, if you try you get "This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771." – Mastro Apr 29 '14 at 01:53
  • Thanks in bunch :) – Manoj Verma Nov 21 '16 at 12:54
199

One more thing to make sure you have is the following set in your web.config:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer>
Mark Boltuc
  • 3,397
  • 1
  • 25
  • 26
  • 23
    That did it for me. Thanks – boca Sep 09 '11 at 19:54
  • 5
    Also solved it for me. Strange it works locally in VS2010 IIS Express without that setting. – Phil Nov 10 '11 at 11:11
  • 8
    If you don't want to set `runAllManagedModulesForAllRequests` (which runs even for static files) you can install a Microsoft hotfix: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5272. – Justin Helgerson Apr 17 '12 at 16:17
  • 10
    Try to avoid this by adding the routing module: http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html – Chris Herring May 10 '13 at 03:40
  • If you are using VS2013 and trying to run on IIS 7.5 - you need to add this – KenL Apr 14 '14 at 15:48
77

Make sure you have is the following set in your web.config:

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

Better solution:

Even though above solution works absolutely fine, it can cause other problem as it runs all your registered HTTP modules on every request (even on every request of .jpg .gif .css .html .pdf etc) and it is obviously waste of resource. Instead

<system.webServer>
<modules>
  <remove name="UrlRoutingModule-4.0"/>
  <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" preCondition="" />
</modules>
</system.webServer>

Make sure preCondition attribute is empty means it will run on all requests. [Read more](http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html,"Read original post")

Premchandra Singh
  • 13,868
  • 4
  • 25
  • 37
  • 6
    This fixed the 403.14 on the root, and 404 on other controller methods for my MVC app. There is still something fishy here, however, because I have another app running on the same server with the same visible site settings, and it works without this setting. This is a web.config created by an SPA project template courtesy of VS 2012, working fine on my box but not when published. – shannon Nov 30 '13 at 03:28
  • 4
    Yes, so my development device contained ``, in the `Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config` and looked to have been modified on the date of my VS 2012 installation. So, the next question is, what is in my other project that is allowing it to function? – shannon Nov 30 '13 at 03:42
  • Note that it is apparently not the `%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir` recommended by the top solution that sets whatever defaults must exist on my development device. That command does not resolve the issue for me once I remove the UrlRoutingModule reference. – shannon Nov 30 '13 at 03:54
  • That works on Windows Server 2008 R2 IIS 7 for ASP.NET MVC 5. Thank you! – Ervi B Mar 09 '16 at 20:32
42

Another reason why someone might get this error is if the file Global.asax is not in the root folder anymore.

ZippyV
  • 11,654
  • 3
  • 33
  • 51
  • 4
    Yep - the installer I wrote didn't bring this file across. Thanks! – zadam Sep 23 '11 at 03:56
  • 4
    This was my problem too. I never would have guessed based on the 403 symptom that my application was missing the Global.asax – Saul Dolgin Jun 28 '13 at 13:09
  • 3
    Also fixed it for me: switched off pre-compilation in publish options (`global.asax` is only file affected). – Richard Oct 15 '14 at 12:58
  • 1
    This did trick for me. The thing is that for me, and I hear for many others, global.asax gets generated every OTHER time I do publish. Did anybody figure out a way to generate it every time? – Greg Z. May 19 '15 at 16:54
  • Thanks, fixed my problems. Application runs on ASP.NET MVC 4.0, Framework 4.0. Hosted on Arvixe. – Joe King Jul 14 '15 at 09:16
  • In my case, with a Web Site rather than Web Application, the Global.asax file had to say CodeFile="Global.asax.cs" rather than CodeBehind="Global.asax.cs". The VS UI kind of fought with me to prevent creating it properly, probably because I was doing the site from scratch rather than using a template. – Jordan Rieger Jan 30 '16 at 00:19
20

I was also receiving this error and discovered that "HTTP Redirection" was not turned on in Windows Server. This blog post points this out as well: http://blogs.msdn.com/b/rjacobs/archive/2010/06/30/system-web-routing-routetable-not-working-with-iis.aspx

toddkitta
  • 565
  • 5
  • 11
  • 6
    Of all the damn things it could have been, this is it. I looked everywhere, and played with security settings for a few hours, aspnet_regiis, and on and on. Sweet baby jesus on a crumbly kaiser roll. – Andrew Backer May 07 '12 at 16:55
  • I have spent a whole day for this. Thank you so much. – Pradeep Sep 15 '12 at 18:57
  • For Windows 8, I still got errors after enabling HTTP Redirection. Had to do this as a second step: Add ASP.NET 4.5 role under Internet Information Services -> World Wide Web Services -> Application Development Features http://serverfault.com/questions/514091/iis-8-asp-net-mvc-http-error-500-19 – dreamerkumar Sep 02 '15 at 19:03
  • The second stop solved my problem. Some machines works without it, but other ones this is essential. Thanks. – Alexis Heijmeijer May 24 '17 at 19:20
15

Sweet Jesus. I tried all of the above things (but found my settings identical). YET ANOTHER SOLUTION if you are having issues:

http://support.microsoft.com/kb/980368

Try installing this KB for your system. If you are seeing 404s it might be because you don't have this update -- and the isapi module just isn't getting found and there's not a lot you can do about that without this!

Sean Anderson
  • 24,467
  • 26
  • 112
  • 219
7

For me on an Azure Server 2012 R2 IIS 8.5 VM with an Asp.Net MVC 5 app (bin deployed MVC 5) I had to do the following from an elevated cmd prompt even though I had 4.5 already installed:

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

Source: http://support.microsoft.com/kb/2736284

I also brute force installed all IIS features with the following PowerShell:

import-module servermanager
add-windowsfeature web-server -includeallsubfeature

Source: http://www.iis.net/learn/install/installing-iis-85/installing-iis-85-on-windows-server-2012-r2

Now my app is working.

Sergey Litvinov
  • 7,118
  • 5
  • 43
  • 63
Jon Kragh
  • 4,169
  • 5
  • 24
  • 26
  • The 'dism' one worked for me (without applying any of the other proposed changes). I just had to switch the '/all' switch to the end to make sure that all 'parent' features were installed as well. – Jeroen Ritmeijer Jun 08 '16 at 17:45
  • This worked for me. Running MVC 5 with .NET 4.5 on Windows Server 2012. IIS by default won't install .NET 4.5. – DPac Dec 09 '16 at 21:41
7

Also u can switch AppPool to Integrated mode. Thnx to Michael Bianchi (https://stackoverflow.com/a/7956546/1143515), I only want to underline that.

Community
  • 1
  • 1
Kalyan00
  • 71
  • 1
  • 2
6

We had a MVC application moved to a new server. .NET 4 and MVC 3 was installed, but we still got “Error 403.14″. In this case, this meant that IIS did not understand that it was dealing with a MVC application, it was looking for the default page.

The solution was simple: HTTP Redirection was not installed on the server.

Server Manager – Roles – Web Server (IIS) – Roles Services – HTTP Redirection: Not installed. Installed it, problem solved.

Bjarne Havnen
  • 91
  • 1
  • 7
5

Also if your app is precompiled you should have

PrecompiledApp.config

in the root folder of your app otherwise you could get HTTP Error 403.14 as well.

pvasek
  • 916
  • 10
  • 10
  • I had the file there for some reason even though my app isn't precompiled. Deleted the file and it works now. Thank you! – vaindil Feb 08 '16 at 16:59
  • I would be really happy if I saw this answer before spending 2 hours and solving it on my own.. – sotn Jan 14 '17 at 11:39
4

I have met the same 404.14 problem suddenly. Finally the problem had been fixed by unchecking "precompile while publishing" in the publish profile settings.

user985287
  • 133
  • 1
  • 6
4

I altered my default route at one point from:

routes.MapRoute(
"Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional }

To:

routes.MapRoute(
"Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index" }

Which gave me your error. Glad someone mentioned routing because I probably would've been on this forever.

Nate-Wilkins
  • 5,158
  • 3
  • 42
  • 60
4

In my case ASP.NET 4.5 is not installed on the server so installing ASP.NET 4.5 fixed the issue.

Saif
  • 91
  • 5
4

You can solve this error by running cmd as admin than enter image description here

Do the same as in picture for windows 32 bit

Just make changes in 64 bit as framework64 instead of framework only Than go to iis and refresh the site
If u still got some error make changes in application pool

4

Another possible solution, if you move around your global.asax, make sure the markup points to the correct MvcApplication class. Hopefully this will save someone in future.

AaronHS
  • 1,220
  • 10
  • 28
4

I had used the WebDeploy IIS Extension to import my websites from IIS6 to IIS7.5, so all of the IIS settings were exactly as they had been in the production environment. After trying all the solutions provided here, none of which worked for me, I simply had to change the App Pool setting for the website from Classic to Integrated.

3

I had another problem that led to this issue.

  • I had ensured my app pool was running .net 4 in integrated mode
  • I had run aspnet_regiis.exe -i
  • I had checked folder permissions were set correctly for the account running my app pool

None of these things worked. It turned out that in my web.config under system.webserver > modules I had the following:

<remove name="WindowsAuthentication" />

Obviously this removed the windows authentication module which seemed to somehow knock everything off kilter.

I hope this helps someone, as this cost me most of an evening!

Paul Suart
  • 6,003
  • 6
  • 38
  • 60
3

As strange as it may seem, reinstalling IIS was what has worked for me, with the following command run from inside the .net version folder:

aspnet_regiis.exe /i

enter image description here

When I first run this command, I begun getting the HTTP Error 403.14. But once I runned the command again it solved the problem.

Obs: Another thing I also did was to remove HTTP Redirect from the server features in Server Management screen before reiinstalling IIS. Maybe this also had an impact in solving the problem, but I am not sure. So, if reinstalling IIS still doesn't work, please try removing HTTP Redirect and try again. Hopefully it may work for you too.

Ulysses Alves
  • 1,960
  • 1
  • 18
  • 32
  • FYI `aspnet_regiis.exe` does not install or reinstall IIS, it just registers a particular .NET framework version, so that it can be used by IIS for hosting applications. – stephen Oct 05 '15 at 17:41
3

The UI is a bit different in the newer versions of Windows Server. Here is where you have to enable ASP.Net in order to get it working on IIS

Fix IIS & Asp.net

2

Yet another reason this can happen - your RouteConfig.cs or WebApiConfig.cs are invalid.

In my case, I had a route defined as such (note the parenthesis instead of curly brace):

...
routeTemplate: "api/(something}"
...
Terry
  • 13,683
  • 8
  • 52
  • 78
  • It works for me! In case I changed `routes.MapRoute( name:"Default", url:"{controller}/{action}/{repositoryId}", defaults:new { controller = "Account", action = "Login", id = UrlParameter.Optional } );`. When I fixed `id = UrlParameter.Optional` on `repositoryId = UrlParameter.Optional` it start to work! – Dmitresky Oct 01 '14 at 00:11
2

Please note for Windows 8 users you need to add/remove windows components and remove the version of .net reboot then re-install in order to register it with IIS. I presume this happens if you get .net 4.5 from visual studio and install IIS afterwards.

Lee.Winter
  • 660
  • 9
  • 16
2

Adding another solution for this issue.

in my Global.asax.cs file I had disabled attempted php files from being consumed by the MVC pipeline using the following:

routes.IgnoreRoute( "{*php}" );

I had done these previously in a MVC2 project and it worked fine, but doing this in my MVC 3 app caused the issue reported above.

TheRightChoyce
  • 2,954
  • 1
  • 19
  • 17
1

If you're running IIS 8.5 on Windows 8, or Server 2012, you might find that running mvc 4/5 (.net 4.5) doesn't work in a virtual directory. If you create a local host entry in the host file to point back to your local machine and then point a new local IIS website to that folder (with the matching host header entry) you'll find it works then.

Mastro
  • 1,455
  • 2
  • 18
  • 46
1

This worked for me and it might be useful to another one.

Maybe all components required are not present or/and not all are registered correctly. In order to solve this, try to uncheck all options inside Control Panel -> Turn Windows features on or off -> Internet Information Services -> World Wide Web Services -> Application Development Features, uncheck all options and recheck all then reset the IIS and check if the problem is solved.

enter image description here

MirlvsMaximvs
  • 1,333
  • 1
  • 21
  • 31
1

To solve this problem without having to resort to 32 bit mode you will have to update the source code for this project

public static void RegisterUrlRoutesFromAttributes(RouteCollection routes)
{
    // Enumerate assembly for UrlRoute attributes.
    List<MapRouteParams> routeParams = new List<MapRouteParams>();
    AppDomain.CurrentDomain.GetAssemblies()
        .ToList()
        .ForEach(assembly => routeParams.AddRange(GetRouteParamsFromAttributes(assembly)));

I have raised this issue as a discussion on the discussion board at the IT cloud codeplex project.

http://itcloud.codeplex.com/discussions/262000

Omar
  • 37,391
  • 42
  • 132
  • 207
0

I created a new namespace (and therefore folder) identical to the route to a controller (e.g. MvcApp/Test/SomeClasses.cs and MvcApp/Controllers/TestController.cs). This resulted also in a 403.14!

Papa Mufflon
  • 11,628
  • 5
  • 22
  • 30
0

For me, the solution was to add the NuGet package Microsoft.AspNet.WebPages (plus it's Razor and Infrastructure dependencies) to my web project.

Infrastructure had to be forcefully reinstalled as it was not added as a reference at first.

Mathieu Diepman
  • 151
  • 1
  • 11
0

In my case .NET CRL Version in Application pool prppertires was set to No managed code (do not know why). Setting it to .NET CRL Version v4.0.30319 solved the problem.

Eugene Rozhkov
  • 653
  • 6
  • 10