Update November 2012 – See my new blog entry Debugging Azure HTTP 500 Errors. This blog no longer applies to Azure.
I was working on a lab using the Windows Azure SDK when I got 500 server error
Not a descriptive error message. The Windows Azure Tools for Microsoft Visual Studio (WATVS) creates a new application pool and web site on the fly when you run your Web application locally. The Azure tools do this to mimic how Azure runs applications in the cloud.
The default setting on IIS for detailed errors is to only display for local addresses. (See http://learn.iis.net/page.aspx/267/how-to-use-http-detailed-errors-in-iis/ ). To get a robust error message you need to use a local address.
You can get a local address by changing the site binding with IIS Manager.
- Select the web site in the connections pane, right click and select Edit Bindings.
- In the Edit Site Bindings dialog, select the binding (the line in blue highlighting below), then select Edit.
- Change the IP address from All Unassigned to *.
- OK, then Close.
- In IIS Manager, in the Actions pane, select Browse *.8x(http) .
Now when you run the Azure application, you’re rewarded with rich error information. In my case, the root Web.config of the application had a duplicate section in the the configSections element. The configSections is used for registering all IIS and Windows Activation System (WAS) sections.
HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error : There is a duplicate ‘system.web.extensions/scripting/scriptResourceHandler’ section defined
I commented out the duplicate line and the application worked.
Alternate approach – Editing ApplicationHost.config
I was doing lots of labs, and each Azure application creates a dedicated web site and application pool (as mentioned previously, to more closely mimic Azure cloud deployment.) As you can see from the Sites pane in IIS manager, I have several Azure applications, and I would have to change the binding for each to get a local address.
Another approach you can take is to edit the ApplicationHost.config file. You should only do this on your development machine, never on a production machine unless you know exactly what you’re doing. ApplicationHost.config is the root file of the IIS 7 configuration system. It includes definitions of all sites, applications, virtual directories and application pools, as well as global defaults for the web server settings (similar to machine.config and the root web.config for .NET Framework settings). Any property set in ApplicationHost.config will apply to all sites, applications, and virtual directories in the machine. Because ApplicationHost.config contains the <section name="scriptResourceHandler" , I got a duplicate error in my root web.config file. To get rich errors information in all web sites, follow these instructions.
- Make a backup of ApplicationHost.config before making any changes to it.
- Edit ApplicationHost.config with Visual Studio’s 32 bit editor by opening the file %windir%\sysnative\inetsrv\config\ApplicationHost.config
32-bit Apps can access the native system directory by replacing %windir%\System32 with %windir%\Sysnative
Alternatively, using a 64 bit editor (such as notepad), open %windir%\System32\inetsrv\config\ApplicationHost.config
- Find the <httpErrors element and add errorMode="Detailed". Replace
<httpErrors errorMode="Detailed" lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
Let me know if this helps out.