WebPermissionAttribute Třída

Definice

Upozornění

Code Access Security is not supported or honored by the runtime.

Určuje oprávnění pro přístup k internetovým prostředkům. Tuto třídu nelze dědit.

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)]
public sealed class WebPermissionAttribute : 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.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class WebPermissionAttribute : 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.Serializable]
public sealed class WebPermissionAttribute : 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)>]
type WebPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type WebPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Serializable>]
type WebPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
Public NotInheritable Class WebPermissionAttribute
Inherits CodeAccessSecurityAttribute
Dědičnost
Atributy

Příklady

Následující příklad ukazuje, jak použít WebPermissionAttribute na metodu.

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

Poznámky

Upozornění

Zabezpečení přístupu kódu (CAS) bylo ve všech verzích rozhraní .NET Framework a .NET zastaralé. Nedávné verze rozhraní .NET nedodržují poznámky CAS a při použití rozhraní API souvisejících s cas generují chyby. Vývojáři by měli hledat alternativní způsoby provádění úloh zabezpečení.

WebPermissionAttribute umožňuje deklarativně určit, které řetězce identifikátoru URI a řetězce regulárního výrazu může vaše třída používat.

Informace o zabezpečení zadané v objektu WebPermissionAttribute jsou uloženy v metadatech cíle atributu, což je třída, na kterou WebPermissionAttribute se použije. Systém přistupuje k tomuto údaji za běhu. Objekt System.Security.Permissions.SecurityAction předaný konstruktoru určuje povolené WebPermissionAttribute cíle. Systém používá metodu WebPermission vrácenou metodou CreatePermission k převodu informací o zabezpečení cíle atributu na serializovatelnou formu uloženou v metadatech.

Poznámka

WebPermissionAttribute se používá pouze pro deklarativní zabezpečení. Pro imperativní zabezpečení použijte odpovídající WebPermission.

Konstruktory

WebPermissionAttribute(SecurityAction)
Zastaralé.

Inicializuje novou instanci WebPermissionAttribute třídy s hodnotou, která určuje akce zabezpečení, které lze provést u této třídy.

Vlastnosti

Accept
Zastaralé.

Získá nebo nastaví řetězec identifikátoru URI akceptované aktuálním WebPermissionAttribute.

AcceptPattern
Zastaralé.

Získá nebo nastaví vzor regulárního výrazu, který popisuje identifikátor URI akceptované aktuálním WebPermissionAttribute.

Action
Zastaralé.

Získá nebo nastaví akci zabezpečení.

(Zděděno od SecurityAttribute)
Connect
Zastaralé.

Získá nebo nastaví připojovací řetězec URI řízený aktuální WebPermissionAttribute.

ConnectPattern
Zastaralé.

Získá nebo nastaví vzor regulárního výrazu, který popisuje připojení URI řízené aktuálním WebPermissionAttribute.

TypeId
Zastaralé.

Při implementaci v odvozené třídě získá jedinečný identifikátor pro tuto Attributetřídu .

(Zděděno od Attribute)
Unrestricted
Zastaralé.

Získá nebo nastaví hodnotu označující, zda je deklarováno úplné (neomezené) oprávnění k prostředku chráněnému atributem.

(Zděděno od SecurityAttribute)

Metody

CreatePermission()
Zastaralé.

Vytvoří a vrátí novou instanci WebPermission třídy .

Equals(Object)
Zastaralé.

Vrací hodnotu, která určuje, zda je tato instance rovna zadanému objektu.

(Zděděno od Attribute)
GetHashCode()
Zastaralé.

Vrátí hodnotu hash pro tuto instanci.

(Zděděno od Attribute)
GetType()
Zastaralé.

Type Získá z aktuální instance.

(Zděděno od Object)
IsDefaultAttribute()
Zastaralé.

Při přepsání v odvozené třídě označuje, zda je hodnota této instance výchozí hodnotou pro odvozenou třídu.

(Zděděno od Attribute)
Match(Object)
Zastaralé.

Při přepsání v odvozené třídě vrátí hodnotu, která označuje, zda se tato instance rovná zadanému objektu.

(Zděděno od Attribute)
MemberwiseClone()
Zastaralé.

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
ToString()
Zastaralé.

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

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

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.

(Zděděno od Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
Zastaralé.

Načte informace o typu objektu, které lze použít k získání informací o typu pro rozhraní.

(Zděděno od Attribute)
_Attribute.GetTypeInfoCount(UInt32)
Zastaralé.

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).

(Zděděno od Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
Zastaralé.

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.

(Zděděno od Attribute)

Platí pro