Represents a permission for a URL identity. This class allows you to control access to resources based on their URL. It is part of the Code Access Security (CAS) model in older versions of .NET Framework, primarily used for managing security policies and code trust.
public sealed class UrlIdentityPermission : System.Security.CodeAccessSecurityAttribute
System.Net.SecurityThe following example shows the syntax for declaring an instance of the UrlIdentityPermission class.
using System;
using System.Net.Security;
using System.Security;
[assembly: UrlIdentityPermissionAttribute("http://www.contoso.com/", SecurityAction.RequestMinimum) ]
public class MyClass { ... }
The following example shows the syntax for the constructor.
public UrlIdentityPermission( PermissionState state )
public UrlIdentityPermission( string url )
The UrlIdentityPermission class is used to grant or deny access to resources based on their network location (URL). In the context of Code Access Security (CAS), it allows administrators to define security policies that restrict the actions of code originating from specific URLs.
For example, you could create a policy that allows code downloaded from http://www.trusted-site.com/ to have more privileges than code from http://www.untrusted-site.com/.
The UrlIdentityPermissionAttribute class can be used to apply security attributes to code elements, such as assemblies or methods, to request or assert specific permissions at compile time.
Note: Code Access Security (CAS) is largely deprecated in favor of modern security models like role-based security and the principle of least privilege. While still present in older .NET Framework versions, its use is generally discouraged in new development.