Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get the absolute path, Uri, authority and fragment associated with Uri using “Uri” class in vb and C# .net.

Author: Maliha Atteeq
Download Source Code : 1054_apps.zip

In this simple article you will how can we get the absolute path, Uri, authority and fragment associated with Uri using “Uri” class in vb and C# .net.

 Uri:

A URI is a compact representation of a resource available to your application on the intranet or Internet. The Uri class defines the properties and methods for handling Uri’s, including parsing, comparing, and combining. The Uri class properties are read-only.

Get the absolute path:

In order to get the absolute path, Uri class provides us a property named as AbsolutePath. This property returns the path associated with the specified Uri. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_getAbsPath_Click(object sender, EventArgs e)

        {

            string path;

            path = obj.AbsolutePath;

            MessageBox.Show("tha absolute path associated with uri is "+path);

        }

 

VB:

Private Sub btn_getAbsPath_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim path As String

    path = obj.AbsolutePath

    MessageBox.Show("tha absolute path associated with uri is " & path)

End Sub

Get the absolute Uri:

In order to get the absolute Uri, Uri class provides us a property named as AbsoluteUri. This property returns the Uri associated with the specified Uri. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

 

        private void btn_getAbsUri_Click(object sender, EventArgs e)

        {

            string uri;

            uri = obj.AbsoluteUri;

            MessageBox.Show("tha absolute uri associated with uri is " + uri);

        }

VB:

Private Sub btn_getAbsUri_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim uri As String

    uri = obj.AbsoluteUri

    MessageBox.Show("tha absolute uri associated with uri is " & uri)

End Sub

Get the authority:

In order to get the authority, Uri class provides us a property named as Authority. This property returns the domain name system (DNS) and the port number associated with the specified Uri. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_getAuthority_Click(object sender, EventArgs e)

        {

            string authority;

            authority = obj.Authority;

            MessageBox.Show("tha DNS of this uri is " + authority);

        }

VB:

Private Sub btn_getAuthority_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim authority As String

    authority = obj.Authority

    MessageBox.Show("tha DNS of this uri is " & authority)

End Sub

Get the fragment:

In order to get the fragment, Uri class provides us a property named as Fragment. This property returns the domain name system (DNS) and the port number associated with the specified Uri. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_getFrag_Click(object sender, EventArgs e)

        {

            string fragment;

            fragment = obj.Fragment;

            if (fragment == string.Empty)

            {

                MessageBox.Show("no fragment found for this uri");

            }

            else

            {

                MessageBox.Show("tha fragment of this uri is " + fragment);

            }

        }

VB:

Private Sub btn_getFrag_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim fragment As String

    fragment = obj.Fragment

    If fragment = String.Empty Then

        MessageBox.Show("no fragment found for this uri")

    Else

        MessageBox.Show("tha fragment of this uri is " & fragment)

    End If

End Sub

Now write the following code on FORM LOAD event:

C#:

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP APPLICATION";

        }

VB:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

   Me.Text = "DEVASP APPLICATION"

End Sub

This simple article tells how we can get the absolute path, Uri, authority and fragment associated with Uri using “Uri” class in vb and C #.net.

Article Comments
Thank you very much. This really helped me with my work. I appreciate your help. Thanks a lot.

Posted on 11/24/2010 1:32:20 AM by fantasy factory chanel nude

Just what I needed, thanks a lot.

Posted on 11/30/2010 10:55:18 AM by computer sales

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Get information about original string, default port, loop backing and file Uri using “Uri” class in vb and C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net