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 Maiximum autometic redirections – response header length – authentication level and decompression methods using HttpWebRequest class C#.net – vb.net.

Author: Shehzad Hemani
Download Source Code : 997_HtmlDocument.zip

In this simple article you will learn that how we can get maximum automatic redirections, response header length, authentication level and decomposition methods for request using HttpWebRequest class.

 Maiximum Autometic Redirections:

If you want to get number of maximum automatic redirections for a request, for this purpose httpwebrequest class provides us a property named MaximumAutomaticRedirections. This property returns and takes an integer value. This integer represents the Maximum Automatic Redirections for a request.

To demonstrate make a window application. Drag one text box and one button on form.

C#

private void btn_maxredirect_Click(object sender, EventArgs e)

        {

            if (count != 0)

            {

                int min = myWebRequest.MaximumAutomaticRedirections;

                string str = min.ToString();

                MessageBox.Show(str);

            }

            else

                MessageBox.Show("FRIRST MAKE request");

        }

VB

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

        If count <> 0 Then

            Dim min As Integer = myWebRequest.MaximumAutomaticRedirections

            Dim str As String = min.ToString()

            MessageBox.Show(str)

        Else

            MessageBox.Show("FRIRST MAKE request")

        End If

    End Sub

This is simple code to get maximum number of automatic redirections.

Maximum Response Header Length:

If you want to get number of maximum response header length for a request, for this purpose httpwebrequest class provides us a property named MaximumResponseHeadersLength. This property returns and takes an integer value. This integer represents the Maximum Response Headers Length for a request.

To demonstrate make a window application. Drag one text box and one button on form.

C#

 private void btn_max_Click(object sender, EventArgs e)

        {

            if (count != 0)

            {

                int max = myWebRequest.MaximumResponseHeadersLength;

                string str = max.ToString();

                MessageBox.Show(str);

            }

            else

                MessageBox.Show("FRIRST MAKE request");

        }

VB

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

        If count <> 0 Then

            Dim max As Integer = myWebRequest.MaximumResponseHeadersLength

            Dim str As String = max.ToString()

            MessageBox.Show(str)

        Else

            MessageBox.Show("FRIRST MAKE request")

        End If

    End Sub

This is simple code to get Maximum Response Headers Length for a request.

Authentication Level:

To get the authentication level of the request we have a property of HttpWebRequest class named AuthenticationLevel. This property takes and returns object of System.Net.Security.AuthenticationLevel class.

To demonstrate make a window application. Drag one text box and one button on form.

C#

private void btn_authlevel_Click(object sender, EventArgs e)

        {

            if (count != 0)

            {

                System.Net.Security.AuthenticationLevel lvl= myWebRequest.AuthenticationLevel;

                string str = lvl.ToString();

                MessageBox.Show(str);

            }

            else

                MessageBox.Show("FRIRST MAKE request");

        }

VB

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

        If count <> 0 Then

            Dim lvl As System.Net.Security.AuthenticationLevel = myWebRequest.AuthenticationLevel

            Dim str As String = lvl.ToString()

            MessageBox.Show(str)

        Else

            MessageBox.Show("FRIRST MAKE request")

        End If

    End Sub

This simple code gets authentication level for request.

Decompression Methods:

If you want to decompression methods for a request, for this purpose we have a property of HttpWebRequest class named AutomaticDecompression. This property takes and returns DecompressionMethods class object.

To demonstrate make a window application. Drag one text box and one button on form.

C#

private void btn_decomp_Click(object sender, EventArgs e)

        {

            if (count != 0)

            {

               DecompressionMethods dcm = myWebRequest.AutomaticDecompression;

                string str = dcm.ToString();

                MessageBox.Show(str);

            }

            else

                MessageBox.Show("FRIRST MAKE request");

        }

VB

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

        If count <> 0 Then

            Dim dcm As DecompressionMethods = myWebRequest.AutomaticDecompression

            Dim str As String = dcm.ToString()

            MessageBox.Show(str)

        Else

            MessageBox.Show("FRIRST MAKE request")

        End If

    End Sub

This is simple code to get decompression methods for request.

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 maximum automatic redirections, maximum response header length, authentication level and decomposition methods for request HttpWebRequest class C#.net – vb.net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Make – Abort request with server - getting read write stream timeout and media type for request using HttpWebRequest class C#.net – vb.net.

Disclaimer - Privacy
© 2002-2017 DevASP.net