ASP MVC in IIS 7 results in: HTTP Error 403.14 - Forbidden
Asked Answered
F

34

149

I'm developing an ASP MVC web project. Now I have a requirement which forces me to deploy to an IIS7 inmiddle of development (to check some features). I'm getting the above mentioned error message whenever I try to type the URL of the web site. (Note: development machine: Vista Home Premium, IIS7)

What I have done until now:

Edited the HOSTS file (C:\WINDOWS\system32\drivers\etc\hosts).

Put two domains in it (127.0.0.1 domain1.com & 127.0.0.1 domain2.com).

Created a folder c:\websites\dirOfApplication and deployed from within Visual Studio 8 to this folder.

In IIS7 created a new site with host name domain1.com and application folder the above.

Typing the address domain1.com in Web browser results in the above error (HTTP Error 403.14 - Forbidden - The Web server is configured to not list the contents of this directory.)

I think I'm missing something but don't know what! Tryed to deploy the files System.Web.Mvc, System.Web.Abstraction & System.Web.Routing wit the same outcome. Whenever I try to hit F5 and run the application, it works fine!

Foudroyant answered 16/11, 2009 at 10:53 Comment(1)
possible duplicate of ASP.NET MVC on IIS 7.5Lorileelorilyn
B
227

Maybe it's useful to someone: After converting my app to MVC 4 with .NET framework 4.5 and installing the framework on my server with IIS 7.0 I encountered the same 'forbidden' error mentioned in the question. I tried all options described above to no avail, when I noticed the

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

was missing from my web.config. After adding this, everything worked. Simple, but easy to overlook...

EDIT:

Of course the solution above will work, but it is indeed a waste of resources. I think it is better to add the routing module as pointed out by Chris Herring in the comments.

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>
Better answered 14/6, 2012 at 8:43 Comment(4)
It turns out that when I uninstalled a NuGet package, that it removed the runAllManagedModulesForAllRequests="true" from my Web.config. Thanks you for mentioning this before I spent all night trying to figure this out.Pulver
try to avoid using this setting by adding the routing module - britishdeveloper.co.uk/2010/06/…Strickle
I had the same problem and it turns out that I didnt copy PrecompiledApp.config to the deployment. putting that in the right place and recycling the app pool fixed it up for me.Middleton
The second one solved the problem for me (thanks), but I've deployed the same site to dozens of servers with neither of these in the web.config and never encountered this issue until today. Is there some more global setting that would affect whether this is needed or not?Whenas
S
126

Answered on SO here, question: 403 - Forbidden on basic MVC 3 deploy on iis7.5

Run aspnet_regiis -i. Often I've found you need to do that to get 4.0 apps to work. Open a command prompt as an Administrator (right click the command prompt icon and select Run as Administrator):

cd \
cd Windows\Microsoft.NET\Framework\v4.xxx.xxx
aspnet_regiis -i

Once it has installed and registered, make sure you application is using an application pool that is set to .NET 4.0.

UPDATE: I just found an issue with this command. Using -i updated all application pools to ASP.NET 4.0.

Using aspnet_regiis -ir installs the version of ASP.NET but does not change any web applications to this version. You may also want to review the -iru option.

Spandrel answered 13/7, 2011 at 21:10 Comment(6)
Worked for me too. After running aspnet_regiis -i command UrlMappingModule was installed in IIS.Acceptable
After installing IIS, I needed to run aspnet_regiis to get everything working even though .NET 4 appeared to be registered already.Snippy
If the framework was installed prior to IIS, then yes you will need to aspnet_regiis.Spandrel
Don't forget that for a 64 bit system it's "Framework64". I.e., Windows\Microsoft.NET\Framework64\v4.xxx.xxxKunzite
For this use, 64 or 32 bit version of aspnet_regiis doesn't matter. Some special cases are listed here: msdn.microsoft.com/en-us/library/k6h9cz8h.aspx#Anchor_1Spandrel
Make sure you application is using an application pool that is set to .NET 4.0. - Thank you, finally managed to deploy my first .NET app! +1Constitutive
W
36

I too ran into this error. All the configuration and permissions were correct. But I forgot to copy Global.asax to the server, and that's what gave the 403 error.

Woosley answered 16/9, 2012 at 19:59 Comment(0)
F
16

It's because of being too sure about what you (me) are doing!

On my machine there is IIS 7 installed but the required ASP.NET component (Control Panel->Programs->Turn On/Off->ASP.NET) was not.

So installing this solved the problem

Foudroyant answered 16/11, 2009 at 12:1 Comment(1)
Yes, for my case. My Windows 10 Local IIS ASP.NET is not turned on. Go to Turn Windows Features on of off > Internet Information Services > World Wide Web Services > Application Development Features > Tick ASP.NET 3.5 & ASP.NET 4.8Asomatous
S
9

I had the same issue. This Microsoft support article fixed it for me.
https://support.microsoft.com/en-us/help/2023146/mvc-2-and-asp.net-4-web-forms-applications-that-use-url-routing-might-return-http-404-errors-when-they-attempt-to-process-extensionless-urls-on-iis-7-and-iis-7.5

In the "Turn Windows Features On or Off" dialog box of the Windows Control Panel "Programs and Features" application, perform the following steps:

  1. Navigate to the following node: Internet Information Services --> World Wide Web Services --> Common HTTP Features
  2. Make sure that the "HTTP Error Redirection" option is selected.

-or-

  1. Navigate to the following node: Internet Information Services --> World Wide Web Services --> Performance Features
  2. Make sure that the "Static Content Compression" option is selected. After either option has been selected, click "OK" to save changes.

Re-enabling either the HTTP Error Redirection module or the Static Content Compression module ensures that ASP.NET and IIS correctly synchronize HTTP pipeline events. This enables the URL routing module to process extensionsless URLs.

Skinhead answered 28/3, 2011 at 12:49 Comment(0)
P
7

In my case following approach helped me out:

  1. aspnet_regiis -i in Windows\Microsoft.Net\Framework

  2. Adding modules to system.webServer

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        ...
    </system.webServer>
    
Photocathode answered 5/4, 2013 at 15:30 Comment(1)
I am guessing you omitted the framework. But open cmd as admin, and run aspnet_regiis -i in Windows\Microsoft.Net\Framework\v4.0.30319Noblesse
P
7

Try to apply the following settings shown below:

1) Give the necessary permission to the IIS_IUSRS user on IIS Server (Right click on the web site then Edit Permissions > Security).

enter image description here

2) If you use .NET Framework 4, be sure that .NET Framework version is v4.0 on the Application Pool that your web site uses.

enter image description here

3) Open Commanp Prompt as administrator and run iisreset command in order to restart IIS Server.

Pulling answered 28/12, 2016 at 14:21 Comment(1)
Tip: If you still get the permission errors after this then you may need to do an iisreset in the cmd as Admin after doing this to get your site running in IIS.Amadoamador
C
5

Please also check, if you are running x64, that you have enabled 32-bit applications in the app pool settings

enter image description here

Chauffeur answered 28/7, 2011 at 21:47 Comment(0)
A
5

I read through every answer here looking for something that worked before I realized that I'm using IIS 10 (on Windows 10 version 2004) and this question is about IIS 7 and almost a decade old.

With that said, run this from an elevated command prompt:

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

The /all will automatically enable the dependent parent features: IIS-ISAPIFilter, IIS-ISAPIExtensions, and IIS-NetFxExtensibility45.

After this, you'll notice two new (in my environment at least) application pool names mentioned .NET v4.5. ASP.NET web apps that were previously using the DefaultAppPool will just work.

enter image description here

Allhallowtide answered 14/12, 2020 at 22:14 Comment(0)
G
4

On the Uncheck "Precompile During Publishing" - I was getting the 403.14 error on a web service I had just written in VS2015 so I rewrote it in VS2013 and was getting the same error. In both cases I had "Precompile During Publishing" on. I unchecked it but was still getting the error. In my case I also had "Delete all existing files prior to publish" but was not deleting everything from the target directory on the server before copying the new published files there. If you don't do that - a "PrecompiledApp.config" file is left behind which causes the problem. Once I deleted that file I was golden on both the VS2013 and VS2015 versions of my web service.

Gymnasium answered 6/8, 2015 at 20:48 Comment(0)
D
3

If the top answers don't work, look for a config named PrecompiledApp.config in the hosting directory and delete it if it exists. This file prevents IISExpress and LocalIIS to work properly. (And I think that's a bug) The content of the file in my case was:

<precompiledApp version="2" updatable="true"/>

And I'm 100% positive that was the problem with my case since I tried everything in 2 hours and tested lots of times with this config.

One more thing: You cannot use aspnet_regiis in newer versions of Windows and IIS so try

dism /online /enable-feature /featurename:IIS-ASPNET45 /all
Dougald answered 14/1, 2017 at 11:37 Comment(0)
B
2

Control Panel > turn windows features on or off > Web Server > Application Development

Check ASP.NET

Bursitis answered 6/2, 2020 at 22:50 Comment(0)
A
1

Please note sometimes wrong Managed pipeline mode will cause this error. There are two choices to select integrated and classic.

Ainsworth answered 22/1, 2013 at 12:44 Comment(0)
F
1

How to Fix “HTTP Error 403.14 – Forbidden The Web server is configured to not list the contents of this directory”

This error occurs when you have MVC 2+ running hosted on IIS 7+, this is because ASP.NET 4 was not registered in IIS. In my case I was creating a MVC 3 project and hosting it on IIS 7.5.

To fix it, make sure you have MVC 2 or above and .Net Framework 4.0 installed, then run a command prompt as administrator and type the following line:

32bit (x86)

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

64bit (x64)

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

Faucher answered 17/1, 2015 at 6:16 Comment(0)
O
1

Check your Global.asax file. In my case, it was empty.

Overstuff answered 7/12, 2016 at 13:8 Comment(0)
S
1

I tried everything here; nothing worked. Problem was in my Web.config file, somehow dependent assembly binding got changed from minimum 1 to minimum 0.

<!-- was -->
<runtime>
    <assemblyBinding>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />


<!-- should have been -->
                <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
Semi answered 6/4, 2017 at 8:11 Comment(0)
B
1

NOTHING WORKED IN THE WORLD FOR ME,

I found out the problem and this might be helpful for someone,

Applicable if you are using Plesk, I just turned this thing off and everything started to work.

Yet, I do not know what is the exact issue with it.

enter image description here

Boswell answered 25/8, 2020 at 9:47 Comment(1)
I am having the same issue and I just turned it off but still not able to get the site to load. Getting the same 403 Forbidden Access.Waterbuck
T
0

I have also encountered this same error, despite all the provided solutions for the following reasons:

  • Missing DLLs
  • Database connection string points to an inaccessible server.
Turbofan answered 11/12, 2011 at 3:55 Comment(0)
D
0

In my case web.config and all files except for the /bin folder were missing (not copied somehow).
Silly, but that was the last thing I have checked.

Darnel answered 3/9, 2012 at 16:49 Comment(0)
D
0

I recently had this error and found that the problem was caused by the feature "HTTP Redirection" not being enabled on my Windows Server. This blog post helped me get through troubleshooting to find the answer (despite being older Windows Server versions): http://blogs.msdn.com/b/rjacobs/archive/2010/06/30/system-web-routing-routetable-not-working-with-iis.aspx for newer servers go to Computer management, then scroll down to the Web Server role and click add role services

Decennium answered 28/1, 2013 at 14:0 Comment(0)
P
0

I'm using: Win Server 2012 R2 / IIS 8.5 / MVC4 / .Net 4.5

If none of the above worked then try this:

Uncheck "Precompile during Publishing"

This kicked my butt for a few days.

Papain answered 7/5, 2015 at 17:6 Comment(1)
@d-kermott, may be my [find][(https://mcmap.net/q/157384/-asp-mvc-in-iis-7-results-in-http-error-403-14-forbidden) would be also useful for you as well ?Statecraft
S
0

With ASP.NET project with C# 4.5 I've solved such problem by installing ASP.NET extension in Web Platform Installer

Statecraft answered 9/7, 2015 at 13:34 Comment(0)
S
0

Also one more things can be possible

install .net framework 4.0 manually

This solution is for IIS7 on window 7

open cmd with administration previleges

go to directory "C:\Windows\Microsoft.NET\Framework\v4.0.30319"

type aspnet_regiis.exe -i

got to your inet manager by typing in run command "inetmgr"

refresh your IIS7

reload the site.

Sib answered 19/7, 2016 at 8:7 Comment(0)
M
0

I know you had this problem in an internal host, but I had experienced such an issue before in an external host and in my case it had it's own resolution, maybe it could save somebody's time:

In fact my website was STOPPED by some reason which currently I'm not aware of, to check it out if you have the same problem, in WebsitePanel main page go to Web -> Websites then select the domain name of your website from the list, after that in the right side of the page just opened, check if you see the word STARTED, else if you see the word STOPPED, make it get started again. That's all.

Milter answered 22/7, 2017 at 12:53 Comment(0)
V
0

I know this is an old topic, but you can also get this error (when you are debugging) if you have a folder named the same as a route in a controller.

For instance, if you have a UserController, with a route called /User and you ALSO have a folder in your solution called "User" then IISExpress will try to browse the folder instead of showing your view.

Valuer answered 30/5, 2018 at 22:55 Comment(0)
A
0

After trying every solution suggested here, I found yet another possible solution: URLScan

The IIS had WebDAV disabled, even in the web.config of my application, WebDAV's handler and module was removed. PUTs still returned a 403 - Forbidden without any log entries in the IIS logs. (GET / POST worked fine).

Turns out the IIS had an active ISAPI Filter (the URLScan) enabled which prevented all PUTs. After removing URLScan, it worked for me.

Arnoldoarnon answered 7/2, 2019 at 13:53 Comment(0)
P
0

My situation was completely different than any of these and the 403:Forbidden error message was a little bit of a red herring.

If your Application_Start() function in the Global.asax module tries to access the web.config and an entry that it's referencing isn't there, IIS chokes and (for some reason) throws the 403:Forbidden error message.

Double-check that you aren't missing an entry in the web.config file that's attempting to be accessed in your Global.asax module.

Provinciality answered 16/9, 2019 at 18:3 Comment(0)
R
0

In case you're like me and have an application using NHibernate and the above answers have not resolved your issue.

You should look at the connection string in your application; possibly in the webconfig file to ensure it is correct.

Rudd answered 24/9, 2019 at 18:33 Comment(0)
B
-1

I have been using Identity Impersonate:

<system.web>
    <identity impersonate="true" userName="domain\username" password="password"/>
</system.Web>

When pushing up to the server you have to give the username access to the Temporary ASP.NET Files folder so it can read/write/execute properly:

C:\Windows\Microsoft.NET\"frameworkversion"\"aspversion"\Temporary ASP.NET Files

Obviously replace "frameworkversion" and "aspversion" with the versions you are using.

Bolognese answered 13/5, 2014 at 9:40 Comment(0)
V
-1

Step 1: Select the Site For which the HTTP Error is produced in IIS and then click on Directory Browsing as shown in the image below:

Step 2: In the Directory Browsing Window in IIS click on Enable in Actions on the right side as shown in the diagram below:

Now Directory Browsing is enabled for your asp.net website, just restart the web application in IIS and Browse the site in your browser and see the result.

Vansickle answered 30/7, 2014 at 21:5 Comment(0)
K
-1

I had this issue but it was fixed easily by going to the Internet Information Services (IIS) Manager, double clicking Directory Browsing and clicking Enable.

In my case, I could access files directly but could not access folders.

Khalsa answered 13/1, 2017 at 18:4 Comment(0)
D
-1

I had mistyped the IP address by one digit, which meant it was going to one of my other servers. Very confusing as you get a .NET error page but from the wrong machine!

Demona answered 5/4, 2018 at 8:7 Comment(0)
S
-1

Adding yet another answer here. If you'r eon Windows 2016 Server running IIS 10.0, it may be because IIS is not installed properly. Here's what I'd suggest if you find yourself here.

  1. In Visual Studio, verify the .NET framework version that you used to develop the app. Right click the project, properties page, application tab. Target Framework. In my case it was 4.6.1.

  2. On the web server, Google 'download .net framework 4.6.1' and go to the MS download page which should properly determine the version you need by your browser user agent. In my case it was X64.

  3. Run the installer. Note that it is safe to do so even if you think it may already be there. It will say 'already installed' if it is.

Note: Now you have to ensure that it is properly 'enabled' as a Windows feature. You also have to verify that ASP.NET IIS components are properly installed and enabled too.

  1. Again on the web server, Go to Server Manager, Add roles and features, then choose role based or feature based. Then click Next.

  2. Ensure that the local server is selected on the destination server tab and click next.

  3. On the server roles tab, expand Web Server IIS and Application Development. I neabled everything but server side includes and Websocket protocols.

  4. Under Management Tools, I chose to enable everything (which includes IIS 6 MMC) because of certain legacy features I wanted, but that's another post.

No reboot was required in my case. Hope this helps somebody.

Slifka answered 8/8, 2019 at 14:48 Comment(0)
D
-3

you can easily solve it by doing following steps :

open iis manager and choose your site you wish to deploy(from the left side treeview panel) and then double click application setting icon to open application setting dialogue and then you should see a grid view on screen so double click on the row named webpages:Enabled and the set value to true (which is false by default).

it worked for me because before I did that I received the same error I even enabled directory browsing (as official iis guide recommended in iis forum) but when I browsed the site sow a list of directories rather than actual web page but when I did the steps above the problem solved and every thing worked fine(but dont forget to grant access for asppool in sql logins after solving this problem of course)

as I said it worked well for me I hope it works well for you too good luck

Diadiabase answered 18/9, 2014 at 10:20 Comment(1)
There is no "application setting" option for a Website in IIS. There is "Advanced Settings" but that does not contain a "webpages:Enabled" option.Tetragrammaton

© 2022 - 2024 — McMap. All rights reserved.