Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal Server Error due to config lockdown when deploying my ASP.NET MVC app to my web host

I'm developing an ASP.NET MVC website on a local Windows Server 2008/IIS7 machine and am I'm now attempting to deploy it to my web host provider, ASPnix. I'm using their Shared Web Hosting service and have been placed on an IIS7 server which they claim supports ASP.NET MVC.

However, when I deploy the application up to their servers, I get an "Internal Server Error".

Here's the Error Summary:

HTTP Error 500.19 - Internal Server Error

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

Here are the relevant portions of the 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".

And the Config Source looks like this:

144:        </modules>
145:        <handlers>
146:            <remove name="WebServiceHandlerFactory-Integrated"/>

The error is coming from the fact that I have a system.webServer section in my web.config file that has a handlers child section. The system.webServer section is the exact config section that was laid down by default when I first created the ASP.NET MVC website in Visual Studio. It has the following XML comment above it:

<!-- 
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0.  It is not necessary for previous version of IIS.
-->

I take the handlers child section out, and the 500 error goes away. Of course, that section is required for an ASP.NET MVC application to work properly in IIS7, so simply taking it only produces other errors (404 errors in this case since routing doesn't work).

The support engineers at ASPnix claim that ASP.NET MVC is installed and configured properly in IIS7 on their servers. I'm not saying I don't believe them as this is the first ASP.NET MVC site that I've built and deployed. However, I can't think of anything I could do to make this work since it appears to be a config issue at a level that I don't have access to.

This issue smells like it would be a common issue with folks trying to deploy ASP.NET MVC to a hosting provider. Has anything run into this either with ASPnix or other web hosting companies and hopefully found a solution?

ps

One odd thing. When researching this issue on the web I find many people saying they had to set the overrideModeDefault attribute their applicationHost.config files of IIS7 to from "Deny" to "Allow". However, my local development server has this set to "Deny" and everything works fine. Even so, I don't have access to the applicationHost.config file anyway on the web host's server.

like image 968
twistedstream Avatar asked Oct 26 '09 05:10

twistedstream


1 Answers

Open IIS Management, Under the main server node, select open Feature Delegation (in Management section)

"Handler Mappings" to "Read/Write" instead of "Read Only"

It looks like your hosting provider unnecessarily locked down IIS.

I was able to recreate the problem on my local IIS 7.5 server.

See this for a global settings reset.

like image 173
Annagram Avatar answered Sep 30 '22 14:09

Annagram