Export (0) Print
Expand All
2 out of 10 rated this helpful - Rate this topic

AspNetHostingPermission Class

Controls access permissions in ASP.NET hosted environments. This class cannot be inherited.

Namespace: System.Web
Assembly: System (in system.dll)

'Declaration
<SerializableAttribute> _
Public NotInheritable Class AspNetHostingPermission
	Inherits CodeAccessPermission
	Implements IUnrestrictedPermission
'Usage
Dim instance As AspNetHostingPermission

/** @attribute SerializableAttribute() */ 
public final class AspNetHostingPermission extends CodeAccessPermission implements IUnrestrictedPermission
SerializableAttribute 
public final class AspNetHostingPermission extends CodeAccessPermission implements IUnrestrictedPermission
Not applicable.

The AspNetHostingPermission class is used in conjunction with code access security to help protect public types in the System.Web namespaces. Code must be assigned at least the Minimal trust level to access protected ASP.NET classes.

The AspNetHostingPermission class's Level property is set by configuring the appropriate trust level in the trust configuration element. By default, the level attribute of the trust configuration element is set to Full. That is, by default, ASP.NET applications run under the Unrestricted level. When an ASP.NET application domain is created, ASP.NET reads the value specified for the level attribute of the trust configuration element, creates an instance of the AspNetHostingPermission class with the specified Level attribute, and then adds the class to the permission set for the application domain. For more information, see ASP.NET Trust Levels and Policy Files.

It is recommended that you set the level attribute of the trust configuration element to High for sites that are trusted. For sites that are not trusted, such as a Web server that hosts sites that run code from an external customer, it is recommended that you set the level attribute of the trust configuration element to Medium.

The permission sets that are defined by default for the .NET Framework (for example, LocalIntranet, Internet, and so on) do not include the AspNetHostingPermission permission. That is, the AspNetHostingPermission permission is only assigned, by default, to applications that are running under Full trust.

The following code example shows a class protected using the AspNetHostingPermission permission. Code must be running with at least MinimalAspNetHostingPermission permission Level in order to create an instance of the class.

Imports System
Imports System.Web
Imports System.Security.Permissions

<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Medium)> _
Public Class CustomAspNetClass

End Class

System.Object
   System.Security.CodeAccessPermission
    System.Web.AspNetHostingPermission
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.