Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

i have create an Asp.net web application, this application exchanges data with SQL server using web service, application is on the network drive on server and i use my pc to working on it, network has a domain and active directory, on running for application the error appears on the first web page:
Server Error in '/' Application.

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.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +42
   System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String typeName, Boolean ignoreCase) +145
   System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) +73
   System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +111
   System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) +279


Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420 

please any one can help me???
Posted
Updated 3-Jul-12 23:27pm
v2

1 solution

SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission

At times, files copied from other machine when directly used are marked as unsafe and thus when we try to use them we get such error. We need to mark it safe and give permission to access it via our code.

Here are few blog entries discussing it in detail with resoultions:
MSDN Blog: System.Security.SecurityException: Request for the permission of type - 1... [^]
MSDN Blog: System.Security.SecurityException: Request for the permission of type - 2...[^]
 
Share this answer
 
Comments
biloo_1983 4-Jul-12 6:22am    
Thank you Sandeep, i read this documents but i think it's not my case!!!
Sandeep Mewara 4-Jul-12 6:34am    
And why do you think so?

It is security permission issue. Make sure it's correct pool that you are using in your IIS and ASPNET has access to files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900