WebPermissionAttribute WebPermissionAttribute WebPermissionAttribute WebPermissionAttribute Class

Definición

Especifica permisos de acceso para recursos de Internet.Specifies permission to access Internet resources. Esta clase no puede heredarse.This class cannot be inherited.

public ref class WebPermissionAttribute sealed : System::Security::Permissions::CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Constructor | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[System.Serializable]
public sealed class WebPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
type WebPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
Public NotInheritable Class WebPermissionAttribute
Inherits CodeAccessSecurityAttribute
Herencia
Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo aplicar WebPermissionAttribute a un método.The following example demonstrates how to apply WebPermissionAttribute to a method.

public:
   // Deny access to a specific resource by setting the ConnectPattern property.
   [method:WebPermission(SecurityAction::Deny,ConnectPattern="http://www.contoso.com/")]

   void Connect()
   {
      // Create a Connection.
      HttpWebRequest^ myWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://www.contoso.com" ));
      Console::WriteLine( "This line should never be printed" );
   }

	// Deny access to a specific resource by setting the ConnectPattern property. 
   [WebPermission(SecurityAction.Deny, ConnectPattern=@"http://www\.contoso\.com/")]

public void Connect() 
     {
        // Create a Connection.  
        HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create("http://www.contoso.com");
        Console.WriteLine("This line should never be printed");
     }


' Deny access to a specific resource by setting the ConnectPattern property. 
<WebPermission(SecurityAction.Deny, ConnectPattern := "http://www\.contoso\.com/.*")> Public Sub Connect()

' Create a Connection.	 
Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest)
Console.WriteLine("This line should never be printed")
   

Comentarios

WebPermissionAttribute permite especificar qué cadenas URI y cadenas de expresiones regulares puede utilizar la clase de forma declarativa.WebPermissionAttribute allows you to declaratively specify which URI strings and regular expression strings your class can use.

La información de seguridad especificada en el WebPermissionAttribute se almacena en los metadatos del destino del atributo, que es la clase a la que WebPermissionAttribute se aplica.The security information specified in the WebPermissionAttribute is stored in the metadata of the attribute target, which is the class to which WebPermissionAttribute is applied. El sistema tiene acceso a esta información en tiempo de ejecución.The system accesses this information at run time. El System.Security.Permissions.SecurityAction pasa al constructor determina los WebPermissionAttribute destinos.The System.Security.Permissions.SecurityAction passed to the constructor determines the allowable WebPermissionAttribute targets. El sistema usa el WebPermission devuelto por la CreatePermission método para convertir la información de seguridad del destino del atributo en un formato serializable almacenado en metadatos.The system uses the WebPermission returned by the CreatePermission method to convert the security information of the attribute target to a serializable form stored in metadata.

Nota

WebPermissionAttribute solo se usa para seguridad declarativa.WebPermissionAttribute is used only for Declarative Security. Para seguridad imperativa, utilice el correspondiente WebPermission.For Imperative Security, use the corresponding WebPermission.

Constructores

WebPermissionAttribute(SecurityAction) WebPermissionAttribute(SecurityAction) WebPermissionAttribute(SecurityAction) WebPermissionAttribute(SecurityAction)

Inicializa una nueva instancia de la clase WebPermissionAttribute con un valor que especifica las acciones de seguridad que pueden ejecutarse sobre esta clase.Initializes a new instance of the WebPermissionAttribute class with a value that specifies the security actions that can be performed on this class.

Propiedades

Accept Accept Accept Accept

Obtiene o establece la cadena URI aceptada por el WebPermissionAttribute actual.Gets or sets the URI string accepted by the current WebPermissionAttribute.

AcceptPattern AcceptPattern AcceptPattern AcceptPattern

Obtiene o establece un modelo de expresiones regulares que describe el URI aceptado por el WebPermissionAttribute actual.Gets or sets a regular expression pattern that describes the URI accepted by the current WebPermissionAttribute.

Action Action Action Action

Obtiene o establece una acción de seguridad.Gets or sets a security action.

(Inherited from SecurityAttribute)
Connect Connect Connect Connect

Obtiene o establece la cadena de conexión URI controlada por el WebPermissionAttribute actual.Gets or sets the URI connection string controlled by the current WebPermissionAttribute.

ConnectPattern ConnectPattern ConnectPattern ConnectPattern

Obtiene o establece un modelo de expresiones regulares que describe la conexión URI controlada por el WebPermissionAttribute actual.Gets or sets a regular expression pattern that describes the URI connection controlled by the current WebPermissionAttribute.

TypeId TypeId TypeId TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
Unrestricted Unrestricted Unrestricted Unrestricted

Obtiene o establece un valor que indica si se declara el permiso completo (sin restricciones) al recurso protegido por el atributo.Gets or sets a value indicating whether full (unrestricted) permission to the resource protected by the attribute is declared.

(Inherited from SecurityAttribute)

Métodos

CreatePermission() CreatePermission() CreatePermission() CreatePermission()

Crea y devuelve una nueva instancia de la clase WebPermission.Creates and returns a new instance of the WebPermission class.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Devuelve un valor que indica si esta instancia es igual que un objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Devuelve el código hash de esta instancia.Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Se aplica a