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 information about original string, default port, loop backing and file Uri using “Uri” class in vb and C# .net.

Author: Maliha Atteeq
Download Source Code : 1053_applicaton.zip

In this simple article you will know how can we get information about original string, default port, loop backing and file 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 information about original string:

In order to know about the original string that whether it is formed or not, Uri class provides us a function named as IsWellFormedOriginalString();. The return type of this function is Boolean. If the string passed to constructor is well informed it returns true otherwise it returns false.

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

C#:

private void btn_getInfo_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsWellFormedOriginalString();

            if (temp == true)

            {

                MessageBox.Show("the original string is well formed");

            }

            else

            {

                MessageBox.Show("the original string is not well formed");

            }

        }

VB:

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

    Dim temp As Boolean

    temp = obj.IsWellFormedOriginalString()

    If temp = True Then

        MessageBox.Show("the original string is well formed")

    Else

        MessageBox.Show("the original string is not well formed")

    End If

End Sub

Get information about default port:

In order to know about the port associated with the Uri is the default port; Uri class provides us a property named as IsDefaultPort. The return type of this property is Boolean. If the port associated with the Uri is the default one it returns true otherwise it returns false.

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

C#:

private void btn_getDefaultPort_Click(object sender, EventArgs e)

        {

            bool temp;

            temp=obj.IsDefaultPort;

            if (temp == true)

            {

                MessageBox.Show("the port associated with this Uri is default port");

            }

            else

            {

                MessageBox.Show("the port associated with this Uri is not a default port");

            }

        }

 

VB:

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

    Dim temp As Boolean

    temp = obj.IsDefaultPort

    If temp = True Then

        MessageBox.Show("the port associated with this Uri is default port")

    Else

        MessageBox.Show("the port associated with this Uri is not a default port")

    End If

End Sub

Get information about Uri file:

In order to know about the Uri that whether it is a file Uri or not, Uri class provides us a property named as IsFile. The return type of this property is Boolean. If the Uri is file Uri it returns true otherwise it returns false.

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

C#:

private void btn_getInformation_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsFile;

            if (temp == true)

            {

                MessageBox.Show("the uri is a file Uri");

            }

            else

            {

                MessageBox.Show("the uri is not a file Uri");

            }

        }

VB:

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

    Dim temp As Boolean

    temp = obj.IsFile

    If temp = True Then

        MessageBox.Show("the uri is a file Uri")

    Else

        MessageBox.Show("the uri is not a file Uri")

    End If

End Sub

Get information about Uri loop backing:

In order to know that whether the Uri references to the local host, Uri class provides us a property named as IsLoopBack. The return type of this property is Boolean. If the Uri references to the local host it returns true otherwise it returns false.

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

C#:

private void btn_getInform_Click(object sender, EventArgs e)

        {

            bool temp;

            temp = obj.IsLoopback;

            if (temp == true)

            {

                MessageBox.Show("the uri references to a local host");

            }

            else

            {

                MessageBox.Show("the uri doesnot references to a local host");

            }

        }

Vb:

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

    Dim temp As Boolean

    temp = obj.IsLoopback

    If temp = True Then

        MessageBox.Show("the uri references to a local host")

    Else

        MessageBox.Show("the uri doesnot references to a local host")

    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 can we get information about original string, default port, loop backing and file Uri using “Uri” class in vb and C# .net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Check IPV6 is multicast or site local or link local by using “IPAdress” class in vb and C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net