Export (0) Print
Expand All

UrlIdentityPermission.Url Property

Gets or sets a URL representing the identity of Internet code.

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

public string Url { get; set; }
/** @property */
public String get_Url ()

/** @property */
public void set_Url (String value)

public function get Url () : String

public function set Url (value : String)

Property Value

A URL representing the identity of Internet code.

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/*.

// Union creates a new permission that is the union of the current permission and
// the specified permission.
private bool UnionDemo()
{

    bool returnValue = true;

    string url1, url2;
    UrlIdentityPermission urlIdPerm1, urlIdPerm2;
    IPermission urlIdPerm3;

    UrlGenerator urlGen1 = new UrlGenerator();
    UrlGenerator urlGen2 = new UrlGenerator();

    urlGen1.ResetIndex();
    while (urlGen1.CreateUrl(out url1))
    {
        urlIdPerm1 = new UrlIdentityPermission(url1);

        Console.WriteLine("**********************************************************\n");
        urlGen2.ResetIndex();
        while (urlGen2.CreateUrl(out url2))
        {

            try
            {
                urlIdPerm2 = new UrlIdentityPermission(url2);

                string firstPermission = url1 == "" | url1 == null ? "null" : url1;
                string secondPermission = url2 == "" | url2 == null ? "null" : url2;
                urlIdPerm3 = (UrlIdentityPermission)urlIdPerm1.Union(urlIdPerm2);
                urlIdPerm3 = urlIdPerm1.Union(urlIdPerm2);

                if (urlIdPerm3 == null)
                {
                    Console.WriteLine("The union of " + firstPermission
                        + " and \n\t" + secondPermission + " is null.");
                }
                else
                {
                    Console.WriteLine("The union of " + firstPermission + " and \n\t"
                        + secondPermission +
                        " = \n\t" + ((UrlIdentityPermission)urlIdPerm3).Url.ToString());
                }
            }
            catch (Exception e)
            {   //Expected exception.
                Console.WriteLine("An exception was thrown for union :" + e.Message);
            }

        }

    }

    return returnValue;

}

// Union creates a new permission that is the union
// of the current permission and
// the specified permission.
private boolean UnionDemo()
{
    boolean returnValue = true;
    String url1[] = new String[1];
    String url2[] = new String[1];
    UrlIdentityPermission urlIdPerm1[] = new UrlIdentityPermission[1];
    UrlIdentityPermission urlIdPerm2[] = new UrlIdentityPermission[1];
    IPermission urlIdPerm3;
    UrlGenerator urlGen1 = new UrlGenerator();
    UrlGenerator urlGen2 = new UrlGenerator();

    urlGen1.ResetIndex();
    while (urlGen1.CreateUrl(urlIdPerm1, url1)) {
        if (urlIdPerm1 == null) {
            continue;
        }

        Console.WriteLine("******************************************" 
            + "****************\n");
        urlGen2.ResetIndex();
        while (urlGen2.CreateUrl(urlIdPerm2, url2)) {
            try {
                if (urlIdPerm2 == null) {
                    continue;
                }
                String firstPermission = (url1[0] == "" 
                    || url1[0] == null) ? "null" : url1[0];
                String secondPermission = (url2[0] == "" 
                    || url2[0] == null) ? "null" : url2[0];

                urlIdPerm3 = ((UrlIdentityPermission)(urlIdPerm1[0].
                Union(urlIdPerm2[0])));
                urlIdPerm3 = urlIdPerm1[0].Union(urlIdPerm2[0]);
                if (urlIdPerm3 == null) {
                    Console.WriteLine(("The union of " + firstPermission 
                        + " and \n\t" + secondPermission + " is null."));
                }
                else {
                    Console.WriteLine(("The union of " + firstPermission 
                        + " and \n\t" + secondPermission + " = \n\t" 
                        + ((UrlIdentityPermission)(urlIdPerm3)).
                        get_Url().ToString()));
                }
            }
            catch (System.Exception e) {
                Console.WriteLine(("An exception was thrown for union :" 
                    + e));
                returnValue = false;
            }
        }
    }
    return returnValue;
} //UnionDemo

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

Community Additions

ADD
Show:
© 2014 Microsoft