Hosting ASP.Net application on a shared server

Posted July 14th, 2009 in Developers by Waldemar Mękal

Sometimes, during development of ASP.Net applications, strange errors occur. There is an exception, which does not tell you anything. There is a lot of googling, many wasted hours and finally this wonderful moment of enlightenment – ‘aha’!

A couple of days ago, there was a similar case. Our client moved his ASP.Net site from a dedicated server to a shared server. As a result I got the following:

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type
'System.Configuration.ConfigurationPermission,
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' failed.]
    System.Security.CodeAccessSecurityEngine.Check(
Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
    System.Security.CodeAccessPermission.Demand() +59
    System.Configuration.BaseConfigurationRecord
.CheckPermissionAllowed(String configKey,
Boolean requirePermission, Boolean isTrustedWithoutAptca) +65

Finally, I found the solution. I had to enclose part of <system.web> section in <location allowOverride=”true” path=”~”> section as presented.

<location allowOverride="true" path="~">

  <system.web>
    <!--The part of config which causes troubles-->
  </system.web>
  ...
</location>

In my case, the problem was related to <httpModules> section because some custom modules were added .

Hope this helps.

Tags: , , ,

No comments so far...

Leave a Reply