Search  
   
Browse by Category
 
Netfirms 24/7 Support .: WINDOWS HOSTING .: ASP.NET .: How do I resolve an error message regarding security policy when running my ASP.NET script?

How do I resolve an error message regarding security policy when running my ASP.NET script?

The following error may result from running an ASP.NET script that requires "full trust":

"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."

The above error means that your script or application requires a trust level not supported by Netfirms.
Netfirms supports Medium Trust Level which is the recommended default for hosters and cannot be changed or overrode with your own policy files. Code in Medium trust applications can read and write its own application directories and can interact with SQL Server™ databases. Medium trust is the recommended setting for a shared server because it allows connections to SQL Server databases and restricts all other permissions to the application root structure.

Or any error that references "System.Web.AspnetHostingPermission" are caused by portions of the code that are not in medium trust.

Medium Trust Summary is available directly from Microsoft's website: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000020.asp

The main constraints placed on medium trust Web applications are:

1. OleDbPermission is not available. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. However, you can use the managed SQL Server provider to access SQL Server databases.
2. EventLogPermission is not available. This means you cannot access the Windows event log.
3. ReflectionPermission is not available. This means you cannot use reflection.
4. RegistryPermission is not available. This means you cannot access
the registry
5. WebPermission is restricted. This means your application can only communicate with an address or range of addresses that you define in the <trust> element.
6. FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy. Your application is granted Read, Write, Append, and PathDiscovery
permissions for your application's virtual directory hierarchy. That is, Medium Trust restricts FileIOPermission in the following manner: "FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy. Your application is granted Read, Write, Append, and PathDiscovery permissions for your application's virtual directory hierarchy. You are also prevented from calling unmanaged code or from using Enterprise Services." A script will only be able to run FileIOPermission operations on files within it's own virtual dir and subfolders, not outside them. In this case, the script calling FileIOPermission operations will need to actually save the file in the same folder as the script or a subfolder of the script's current folder.

7. You are also prevented from calling unmanaged code or from using Enterprise Services.

TIP: When testing your ASP.NET site locally on your own machine, you can test the security level that your ASP.NET site will run in. The instructions on how to check and configure your own IIS's web server trust level is available online at http://msdn2.microsoft.com/en-us/library/ms998341.aspx

NOTE: For additional ASP.NET support and resources we recommend the following web sites:


How helpful was this article to you?


.: Powered by Lore 1.5.6
Visit Netfirms.com Web Hosting | Copyright © 1998 - 2009 Netfirms, Inc. All Rights Reserved.