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.
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.
Config Error : There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
I commented out the duplicate line and the application worked.
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.
<httpErrors errorMode="Detailed" lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
Let me know if this helps out.