268

I have a simple webAPI build by Visual Studio 2013. It works well when I run it from VS13 but when I copy the project in local IIS it gives me the following error.

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module IIS Web Core

Notification BeginRequest

Handler Not yet determined

Error Code 0x80070021

Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

Config File \?\C:\inetpub\wwwroot\APITeslin\web.config

Config Source:

36:   <system.webServer>  
37:     <handlers>  
38:       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
Umar Abbas
  • 4,041
  • 2
  • 23
  • 21
  • 1
    This is likely to be Windows authentication disabled in IIS, but required in your application's web.config. – SpaceBison Nov 18 '13 at 13:05
  • 7
    possible duplicate of [IIS - this configuration section cannot be used at this path (configuration locking?)](http://stackoverflow.com/questions/9794985/iis-this-configuration-section-cannot-be-used-at-this-path-configuration-lock) – CodeCaster Nov 18 '13 at 13:05
  • @SpaceBison how can i enable Window Authentication in IIS8 ? – Umar Abbas Nov 18 '13 at 13:22
  • Here is link of my webconfig file. http://icopter.co.uk/Webconfig.txt – Umar Abbas Nov 18 '13 at 13:23
  • Have you considered using URL rewrite module? –  Nov 18 '13 at 14:16

21 Answers21

414

Got precisely the same error and came to this question. As @SpaceBison mentioned in comments, this answer describes the solution - https://stackoverflow.com/a/12867753/404099. I spotted it too late and it misses some steps. This is what worked for me:

Windows Server 2012, IIS 8.5. Should work for other versions too.

  • Go to server manager, click add roles and features
  • In the roles section choose: Web Server
    • Under Security sub-section choose everything (I excluded digest, IP restrictions and URL authorization as we don't use them)
    • Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries
  • In the features section choose: NET 3.5, .NET 4.5, ASP.NET 4.5
  • In the web server section choose: Web Server (all), Management Tools (IIS Management Console and Management Service), Windows Authentication - if you are using any of it
Community
  • 1
  • 1
Ilia Barahovsky
  • 10,158
  • 8
  • 41
  • 52
  • 19
    All I had to add was the .NET 4.5 items in the AppDev section and the Features section. The extensibility item also forced the 2 ISAPI entries. – Bill Jun 02 '14 at 23:16
  • 1
    Finally, a solution to solve my ailments. Thanks, it makes sense, and its simple enough. It always seems to be missing features and roles these days... – Alexandru Dec 23 '14 at 02:52
  • 1
    the ServerManager is not available in Windows7 Home, how to fix it? – knocte Jan 13 '15 at 19:45
  • 4
    @knocte - in Windows 7 you can enter the "Uninstall or change a program" and then hit "Turn Windows features on or off". This is not the same as the Server Manager, but you can install IIS and related features this way. – Ilia Barahovsky Jan 15 '15 at 05:04
  • WORKED (didn't have to install 3.5), did have to recycle the app pool for it to take effect. (thx) – Jim Mar 04 '15 at 01:20
  • Great! It works properly, neither I install .NET3.5. – NEOLPAR May 19 '16 at 08:04
  • Where is the Server Manager? I have a PC with Windows 8 and IIS 8.5 – Axel Dec 13 '16 at 22:48
  • Worked for me too. But I only need this part "Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries". Using Win Server 2016. – ramires.cabral Oct 01 '18 at 20:05
  • Enabling All Security did fr me – Vithu Sep 13 '20 at 04:59
  • worked for me, tried the link mentioned (windows 10, VS-19). thanks man – Deep Roy Aug 03 '21 at 14:31
163

I got this error while trying to host a WCF service in an empty ASP.NET application. The whole solution was using .NET 4.5 platform, on IIS 8.5 running on Windows 8.1. The gotcha was to

  1. Open up "Turn Windows Features on or off"

  2. Go to WCF section under ASP.NET 4.5 advanced services

  3. Check HTTP Activation.

  4. You'll be asked to restart the system.

    Screen Shot

This should Fix the HTTP 500.19!

EDIT 11-FEB-2016 Just got an issue on Windows 10 Pro, IIS 10, This time, it was an HTTP 404.0. The fix is still the same, turn on "HTTP Activation" under Windows Features -> .NET Framework 4.6 Advanced Services -> WCF Services -> HTTP Activation

Community
  • 1
  • 1
Sudhanshu Mishra
  • 6,523
  • 2
  • 59
  • 76
55

I also was getting the same problem but after brain storming with IIS and google for many hours. I found out the solution. This error is because some settings are disabled in IIS applicationHost.config.

Below are the steps to solution:

  1. Go to C:\Windows\System32\inetsrv\config\applicationHost.config and open in notepad
  2. Change the following key value present in

    • <section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"

    • <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"

It worked for me.

David Gardiner
  • 16,892
  • 20
  • 80
  • 117
SeeTheC
  • 1,560
  • 12
  • 14
  • 2
    Thank you. After doing these steps the next error appeared. I could solve it like described here: http://stackoverflow.com/a/30594003/434742 – Krisztián Balla Jul 21 '16 at 07:21
32

If you're running IIS on that computer for the first time, you should try running the ASP.NET IIS registration tool (aspnet_regiis.exe).

Here's how to do that: If you're using .net framework v4, open command prompt as an administrator, and change directory to your .net framework base folder using:

CD C:\Windows\Microsoft.NET\Framework\v4.0.30319

or, if you're using a 64 bit computer, use:

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

when you've successfully navigated to the appropriate directory, execute the ASP.NET IIS registration tool using:

aspnet_regiis -i

If you're using a different .NET framework version, simply replace v4.0.30319 with the appropriate folder name.

Hope this helps.

Ibrahim Dauda
  • 645
  • 8
  • 19
  • I am trying to run two different VS projects on my iis server (virtual machine); one works, one doesn't... The above helped get the first working; is there any reason the 2nd shouldn't work? – JosephDoggie Dec 01 '14 at 17:45
  • 7
    I used this method in the past but aspnet_regiis is no longer supported on Windows 8.1. To register 4.5 use the Programs and Features > Turn Windows features on or off > Information Information Services > World Wide Web Services > Application Development Features > Check ASP.NET 4.5 and whatever else you might need. – masterwok Dec 02 '14 at 16:14
  • 1
    this needs to be run as Administrator (right click on cmd.exe icon -> run as administrator), and even it if can detect errors during the operation (and produce a log file), it worked for me! – knocte Jan 13 '15 at 19:53
  • 2
    For IIS 8.5 on Windows 8.1 (or Windows Server 2012) this does not work. I got the following prompt:C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i Start installing ASP.NET (4.0.30319.33440). 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. – Sudhanshu Mishra Feb 08 '15 at 17:37
  • Thanks!! It works for me with IIS 10 and Windows 10 :) – Víctor Beltrán Aug 10 '17 at 15:57
27

I solved this by doing the following:

WebServer(ISS)->WebServer->Application Development
add .NET Extensibility 3.5
add .NET Extensibility 4.5
add ASP.NET 4.5
add ISAPI Extensions
add ISAPI Filters

enter image description here

josliber
  • 43,891
  • 12
  • 98
  • 133
GIOESCOM
  • 271
  • 3
  • 2
11

On Windows 8.1, IIS 8.5 the solution for me was to register 4.5 from the control panel:

Programs and Features > Turn Windows features on or off > Information Information Services > World Wide Web Services > Application Development Features > Select ASP.NET 4.5

Click OK.

Jon
  • 3,173
  • 3
  • 39
  • 66
8

As the error idnicates - "This happens when the section is locked at a parent level". To unlock the section you can use appcmd.exe and execute the following command:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers -commitpath:apphost

For more information on about section locking and what a parent configuration context is refer to IIS documentation.

Taras Alenin
  • 8,094
  • 4
  • 40
  • 32
7

If it is windows 10 then open the powershell as admin and run the following command:

dism /online /enable-feature /all /featurename:IIS-ASPNET45
CKE
  • 1,533
  • 19
  • 18
  • 29
user2912206
  • 91
  • 1
  • 1
7

On Windows 8.1 or 10 include the .Net framework 4.5 or above as shown below

enter image description here

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
4

In our case, we struggled with this error for quite some days. It turns out that in control panel, programs, turn windows features on or off.

We selected Internet Information Services, world wide web services, Application development features and there we check the set of features associated with our development environment. For example: ASP.NET 4.6. .NET Extensibility 4.6, etc.

It works!

  • 1
    This fixed my issue as well. So the issue was ultimately that after adding IIS to my local machine, I didnt enable to proper features. This resolved it. THnks. – Judy007 Jul 07 '18 at 23:37
3

Try unlocking the relevant IIS (7.5) configuration settings at server level, as follows:

  1. Open IIS Manager
  2. Select the server in the Connections pane
  3. Open Configuration Editor in the main pane
  4. In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
  5. Click Unlock Attribute in the right pane
  6. Repeat for any other settings which you need to unlock
  7. Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
Chris
  • 3,210
  • 1
  • 33
  • 35
  • This is almost helpful but on IIS 7 there is no "defaultPath" under system.webServer – Djorge Jun 10 '15 at 13:05
  • By that he means if you are looking to update Windows Authentication then you will find it in the path system.webServer -> Security -> Authentication. – Mido Jul 14 '16 at 14:08
3

In my case, there were rules for IIS URL Rewrite module but I didn't have that module installed. You should check your web.config if there are any modules included but not installed.

HasanG
  • 12,734
  • 29
  • 100
  • 154
  • 1
    Just installed everything else needed, but still not got it to work. Then, I just installed the URL Rewrite module, and got it working! Thanks! – Vitox Dec 31 '18 at 07:59
  • If URL Rewrite module is missing, the error code won't be 0x80070021. – Lex Li Jun 22 '20 at 12:35
1

Your web.config describes that you're using forms authentication - make sure you enable forms authentication and disable anonymous authentication in IIS under the Authentication menu, for the website that is running in IIS.

SpaceBison
  • 3,704
  • 1
  • 30
  • 44
1

I got Error Code 0x80070021 when migration IIS7 to IIS 10 in win 2016 box . . Below steps helped me to fix it . source

manually change value from "Deny" to "Allow" for below settings in

%windir%\system32\inetsrv\config\ applicationHost.config

under section:system.webServer

<section name="handlers" overrideModeDefault="Deny" />
Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
0

Please <staticContent /> line and erased it from the web.config.

Erdogan
  • 952
  • 12
  • 26
0

Well, we're using Amazon Web Services and so we are looking to use scripts and programs to get through this problem. So I have been on the hunt for a command line tool. So first I tried the trick of running

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

but because I'm running a cloud based Windows Server 2012 it complained

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.

and I Googled and found the official Microsoft Support Page KB2736284. So there is a command line tool dism.exe. So I tried the following

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

but it complained and gave a list of featurenames to try, so I tried them one by one and I tested my WebAPI webpage after each and it worked after the bottom one in the list.

dism /online /enable-feature /featurename:IIS-ApplicationDevelopment
dism /online /enable-feature /featurename:IIS-ISAPIFilter 
dism /online /enable-feature /featurename:IIS-ISAPIExtensions 
dism /online /enable-feature /featurename:IIS-NetFxExtensibility45 

And so now I can browse to my WebAPI site and see the API information. That should help a few people. [However, I am not out of the woods totally myself yet and I cannot reach the website from outside the box. Still working on it.]

Also, I did some earlier steps following other people responses. I can confirm that the following Feature Delegation needs to be change (though I'd like to find a command line tool for these).

In Feature delegation

Change 
'Handler Mappings' from Read Only to Read/Write

Change 
'Modules' from Read Only to Read/Write

Change 
'SSL Settings' from Read Only to Read/Write
S Meaden
  • 8,050
  • 3
  • 34
  • 65
0

Check if IIS server installed the URL rewrite feature.
If it is not installed then make sure your web.config file don't have the URL rewrite related configuration

<!-- Make sure don't have below config, if server have not installed url rewrite feature. -->
<rewrite>
  <rules>
    <rule name="Fail bad requests">
      <match url=".*"/> ...

Some time we copied the config from legacy server and straight away deploy to brand new server, then we may encounter such kind of 500 issue.

Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113
0

Had this today on a Windows 2016 Core server I resolved the issue by ensuring the components were installed as mentioned by GIOESCOM and then I repaired the SDK's in my case for .NET Core 3.1, .NET 5 and .NET 6 which resolved the issue and the ASP.NET 4.7.2 MVC web app worked.

Trevor
  • 1,561
  • 1
  • 20
  • 28
0

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”)

Hello guys

From older IIS and server

We may encounter the following error when we want to run our application on IIS 10 built on the new Microsoft Windows Server 2016.

HTTP Error 500.19 – Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false The solution is very simple.

Follow the C:\Windows\System32\inetsrv\config file path from your computer. Change the overrideModeDefault=”Deny” part in the applicationHost config file to “Allow”. Then when you restart IIS, the problem will be fixed.

-2

It works and save my time. Try it HTTP Error 500.19 – Internal Server Error – 0x80070021 (IIS 8.5)

ozil
  • 6,930
  • 9
  • 33
  • 56
iurewa
  • 1
  • 1
-3

The solution that worked for me was to delete my current Web.config and add a new one. That solved the problem for me