Knowledge Base
smartDBforms.NET for ASP.NET 2
 
 
Knowledge Base Forum
Search knowledge base:

PRB: SecurityException for System.Web.AspNetHostingPermission when using UNC path
Monday, 25 June 2007
The following exception appears when opening the website: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

SYMPTOMS

The following exception appears when opening the website.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]

   System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0

   System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String typeName, Boolean ignoreCase) +140

   System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) +295

   System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +163

   System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) +192

 


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

 

 

CAUSE

This problem appears when the website home directory is an UNC path. In this case the code in the website does not have access rights to dynamically load .NET types. For example the method System.Reflection.Assembly.GetTyp cannot be used in this case. The specific error appears when an .aspx or .ascx page uses the Inherits attribute to change its base class.

 

 

RESOLUTION

You can use one these methods to resolve the issue

Map the shared folder as a Network Drive

The Home Directory needs to be a directory located on web server computer, not a UNC name ( or a share located
on another comptuer). A workaround is to map the shared folder as a network drive and then use in the form of  Drive Letter:\

Set the shared folder as trusted location

The network share can be granted full trust by using the .NET CASPOL tool or the Microsoft .NET Framework Configuration utility( mscorcfg.msc ).

For more information see:

 


Page Options: format for printing  Format for Printer

How would you rate the quality of this content?
Poor - - Excellent
Comments? 
Overall Rating:
Comments Left:
Left on Sunday, 09 December 2007 by Anonymous
Comments:
No ratings available.
Left on Friday, 03 August 2007 by Anonymous
Comments: thanks
Copyright 2006-2008 Adillis Terms Of Use Feedback Contact Us