This documentation is archived and is not being maintained.

UrlIdentityPermission Constructor (String)

Initializes a new instance of the UrlIdentityPermission class to represent the URL identity described by site.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public UrlIdentityPermission (
	string site
)
public UrlIdentityPermission (
	String site
)
public function UrlIdentityPermission (
	site : String
)

Parameters

site

A URL or wildcard expression.

Exception typeCondition

ArgumentNullException

The site parameter is a null reference (Nothing in Visual Basic).

FormatException

The length of the site parameter is zero.

ArgumentException

The URL, directory, or site portion of the site parameter is not valid.

The complete URL is considered, including the protocol (HTTP, HTTPS, FTP) and the file, for example: http://www.fourthcoffee.com/process/grind.htm/.

URLs can be matched exactly or by a wildcard in the final position, for example: http://www.fourthcoffee.com/process/*. URLs can also contain a wildcard ("*") prefix at the dot delimiter. For example, the URL name string http://www.fourthcoffee.com/process/grind.htm/ is a subset of http://*.fourthcoffee.com/process/grind.htm/ and http://*.com/process/grind.htm/.

NoteNote

New in version 2.0, for performance reasons, an invalid URL does not cause an argument exception at the time the new class instance is created. The argument exception will occur when one of the set operations (Union, Intersect, or IsSubsetOf) is executed. A demand on the permission causes IsSubsetOf to be called by the security infrastructure. The demand will fail because of the argument exception, resulting in a SecurityException being thrown. In this case the original ArgumentException exception will not be seen.

// CreateUrl creates a UrlIdentityPermission.

public bool CreateUrl(out string url)
{


    if (urlIndex == myUrl.Length)
    {

        url = "";
        urlIndex++;
        return true;

    }
    if (urlIndex > myUrl.Length)
    {
        url = "";
        return false;
    }

    url = myUrl[urlIndex++];

    return true;
    
}

// CreateUrl creates a UrlIdentityPermission.
public boolean CreateUrl(UrlIdentityPermission urlPerm[], String url[])
{
    UrlIdentityPermission urlP = null;
    if (urlIndex == myUrl.length) {
        urlPerm[0] = new UrlIdentityPermission(PermissionState.None);

        url[0] = "";
        urlIndex++;
        return true;
    }
    if (urlIndex > myUrl.length) {
        urlPerm = null;
        url[0] = "";
        return false;
    }
    url[0] = myUrl[urlIndex++];
    try {
        urlP = new UrlIdentityPermission(url[0]);
        urlPerm[0] = urlP;
        return true;
    }
    catch (System.Exception e) {
        Console.WriteLine(("Cannot create UrlIdentityPermission : " 
            + url + " " + e));
        urlPerm[0] = new UrlIdentityPermission(PermissionState.None);
        url[0] = "";
        return true;
    }
} //CreateUrl

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: