Export (0) Print
Expand All

UrlIdentityPermission.Url Property

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

[Visual Basic]
Public Property Url As String
[C#]
public string Url {get; set;}
[C++]
public: __property String* get_Url();
public: __property void set_Url(String*);
[JScript]
public function get Url() : String;
public function set Url(String);

Property Value

A URL representing the identity of Internet code.

Remarks

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

Example

[Visual Basic] 
' Union creates a new permission that is the union of the current permission and 
' the specified permission.
Private Function UnionDemo() As Boolean

    Dim returnValue As Boolean = True

    Dim url1, url2 As String
    Dim urlIdPerm1, urlIdPerm2 As UrlIdentityPermission
    Dim urlIdPerm3 As IPermission

    Dim urlGen1 As New UrlGenerator()
    Dim urlGen2 As New UrlGenerator()

    urlGen1.ResetIndex()
    While urlGen1.CreateUrl(urlIdPerm1, url1)
        If urlIdPerm1 Is Nothing Then
            GoTo ContinueWhile1
        End If
        Console.WriteLine("**********************************************************" & ControlChars.Lf)
        urlGen2.ResetIndex()
        While urlGen2.CreateUrl(urlIdPerm2, url2)

            Try
                If urlIdPerm2 Is Nothing Then
                    GoTo ContinueWhile2
                End If
                Dim firstPermission As String = IIf(url1 = "" Or url1 Is Nothing, "null", url1)
                Dim secondPermission As String = IIf(url2 = "" Or url2 Is Nothing, "null", url2)
                urlIdPerm3 = CType(urlIdPerm1.Union(urlIdPerm2), UrlIdentityPermission)
                urlIdPerm3 = urlIdPerm1.Union(urlIdPerm2)

                If urlIdPerm3 Is Nothing Then
                    Console.WriteLine("The union of " & firstPermission & "  and " & ControlChars.Lf & ControlChars.Tab & secondPermission & " is null.")
                Else
                    Console.WriteLine("The union of " & firstPermission & "  and " & ControlChars.Lf & ControlChars.Tab & secondPermission & " = " & ControlChars.Lf & ControlChars.Tab & CType(urlIdPerm3, UrlIdentityPermission).Url.ToString())
                End If
            Catch e As Exception
                Console.WriteLine("An exception was thrown for union :" & e.ToString())
                returnValue = False
            End Try
ContinueWhile2:
        End While
ContinueWhile1:
    End While


    Return returnValue
End Function 'UnionDemo


[C#] 
// 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 urlIdPerm1, out url1)) 
    {
        if(urlIdPerm1 == null) continue;
        
        Console.WriteLine("**********************************************************\n");
        urlGen2.ResetIndex();
            while(urlGen2.CreateUrl(out urlIdPerm2, out url2)) 
            {

                try
                {
                    if(urlIdPerm2 == null) continue;

                    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) 
                {
                    Console.WriteLine("An exception was thrown for union :" + e);
                    returnValue=false;
                }

        }
        
    }

    return returnValue;

}

[C++] 
// 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(&urlIdPerm1, &url1)) {
      if (urlIdPerm1 == 0) continue;

      Console::WriteLine(S"**********************************************************\n");
      urlGen2->ResetIndex();
      while(urlGen2->CreateUrl(&urlIdPerm2, &url2)) {
         try {
            if (urlIdPerm2 == 0) continue;

            String* firstPermission = url1->Equals(S"") || url1 == 0 ? S"null" : url1 ;
            String* secondPermission = url2->Equals(S"") || url2 == 0 ? S"null" : url2;
            urlIdPerm3 = dynamic_cast<UrlIdentityPermission*>(urlIdPerm1->Union(urlIdPerm2));
            urlIdPerm3 = urlIdPerm1->Union(urlIdPerm2);

            if (urlIdPerm3 == 0) {
               Console::WriteLine(S"The union of {0}  and \n\t{1} is null.",
                  firstPermission,
                  secondPermission);
            } else {
               Console::WriteLine(S"The union of {0}  and \n\t{1} = \n\t{2}",
                  firstPermission,
                  secondPermission,
                  (dynamic_cast<UrlIdentityPermission*>(urlIdPerm3))->Url);
            }
         } catch (Exception* e) {
            Console::WriteLine(S"An exception was thrown for union : {0}", e);
            returnValue=false;
         }
      }
   }
   return returnValue;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

UrlIdentityPermission Class | UrlIdentityPermission Members | System.Security.Permissions Namespace

Show:
© 2014 Microsoft