HTTP Error 500.19 - The requested page cannot be accessed
The HTTP Error 500.19 can be a frustrating error to resolve when hosting a website on IIS. There are several different causes of this error, but by taking a systematic approach to troubleshooting, you can quickly fix the issue and get your website back online. In this post, I'll show you the most common causes of this error.
So, you've tested a website locally and everything works. Then, after deploying the website to IIS, Azure, or a third place, errors start happening. Nothing is as frustrating than errors happening after a deployment only. A quick note about .NET and ASP.NET versions before we begin. The issues in this guide can happen on both ASP.NET (the old version) and ASP.NET Core. While a
web.config file doesn't cause as many problems on ASP.NET Core, it is still perfectly valid to have one.
Malformed XML in web.config
One of the most common causes of an HTTP Error 500.19 is invalid XML in the
web.config file. You probably already know different causes of malformed XML like missing or duplicate closing tags. To fix this, you'll need to check the
web.config file for any errors in the XML structure and fix them. Spotting the cause of the syntax error can be hard. As an example, take a look at the following XML:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="ExtensionlessUrlHandler-Integrated-4.0" path=*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer> </configuration>
Did you spot the error? There's a missing
" character in the
path attribute. Using a text editor with proper XML writing capabilities is key here. And never edit the
web.config file directly on the server hosting IIS.
We have developed a couple of free tools that will help you validate the
web.config file. The XML formatter and validator can tell you if the file is valid or not. We also have two other tools, but I'll save those for later in this post since they are both concerned with the content and not the syntax. In addition, you can use command line tools to check the XML structure like xmllint.
Missing or incorrect permissions on the website's root directory
Another cause could be incorrect permissions on the website's root directory. IIS requires the
IIS_IUSRS group to have
execute permissions. To fix this, can give the
IIS_IUSRS group the appropriate permissions using the
icacls C:\inetpub\wwwroot\ /grant IIS_IUSRS:(OI)(CI)RX
You can verify the folder permissions using the
Get-Acl PowerShell command:
Get-Acl C:\inetpub\wwwroot\ | Format-List
The Windows UI provides a similar output by right-clicking the
wwwroot folder and selecting Properties but I'll leave that for another post.
A missing or incorrect section in the web.config file
web.config file is missing a required section or the section is configured incorrectly, you may also get the error. For example, if you are using a custom handler for a specific file extension, you must register it in the
system.webServer section of the
web.config file as follow:
<configuration> <system.webServer> <handlers> <add name="CustomHandler" path="*.custom" verb="*" type="MyCustomHandler, MyAssembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" /> </handlers> </system.webServer> </configuration>
You can use the
appcmd command-line tool to check for the existence of specific sections and modules registered in the
web.config file. To check for the existence of the
appcmd list config -section:system.webServer/handlers /config:C:\inetpub\wwwroot\web.config
These types of errors relate to the content of the file and not the syntax. Microsoft made an XML Schema for
web.config files that is distributed alongside .NET and Visual Studio. When editing
web.config files in Visual Studio, you should already get IntelliSense which will help you input the right elements and attributes.
As mentioned earlier in the post, we have developed two free tools to help you debug problems with the content in
web.config files. The Web.config Validator will validate the XML for syntax problems and run a check of the content towards the XML Schema. In addition, we have developed a range of other checks that are not currently catched by the schema.
The other tool is for developers using config transformations. By inputting the content of a
web.release.config file in the Web.config Transformation Tester tool, you will see the output generated by config transformations. It is perfectly possible to generate output XML that doesn't conform to the XML schema with config transformation, so make sure to inspect the output.
Incorrect Server or Site Configuration
Another cause is an incorrect server or site configuration in IIS. This can happen if the server is missing a required role or feature, or if the website is not configured correctly. To fix this, you should verify that the needed features are installed.
You can use the Server Manager or the command-line tool
dism.exe to check for the roles and features that are installed on the server:
dism /online /get-features
The tool needs a command prompt in Administrator mode and outputs text similar to this:
Additionally you can use the IIS manager or the
appcmd tool to check the website configuration:
appcmd list site /site.name:"Website name"
Always spend some time looking through your log output for additional details. In case you have elmah.io installed, detailed information is available on the logged error. IIS log files can also provide valuable information about the specific error. The Windows Event Viewer is a good place to look for any additional details, especially in cases where the error message does not provide enough information. This is often the case from a production server where you don't see the yellow or white screen of death as when running locally.
As shown in the post, the HTTP Error 500.19 can be caused by several issues. By checking the
web.config file for malformed XML and that the content validates against the XML schema, checking the permissions on the website's root directory, and inspecting the server and website configuration, you can hopefully resolve this error. Remember that the troubleshooting steps may vary depending on the specific error message, so always check the error message details. Ideally, you want to include enough logging to quickly resolve errors like this, but in most cases, using a few free tools and inspecting built-in log files should be sufficient.
elmah.io: Error logging and Uptime Monitoring for your web apps