WebHeaderCollection.Add inserts the specified header into the collection. : WebHeaderCollection « Network Remote « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Network Remote » WebHeaderCollectionScreenshots 
WebHeaderCollection.Add inserts the specified header into the collection.
 
Imports System.IO
Imports System.Net
Imports System.Text

public class MainClass
    Public Shared Sub Main()
         Try
            Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
            Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebRequest.Headers
            myWebHeaderCollection.Add("Accept-Language:da")

            myWebHeaderCollection.Add("Accept-Language","en;q" + ChrW(61"0.8")

            Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

            myHttpWebResponse.Close()
        Catch As ArgumentException
            Console.WriteLine(e.Message)
        Catch As WebException
            Console.WriteLine(e.Message)
            If e.Status = WebExceptionStatus.ProtocolError Then
                Console.WriteLine("Status Code : {0}", CType(e.Response, HttpWebResponse).StatusCode)
                Console.WriteLine("Status Description : {0}", CType(e.Response, HttpWebResponse).StatusDescription)
                Console.WriteLine("Server : {0}", CType(e.Response, HttpWebResponse).Server)
            End If
        Catch As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub 
End Class

   
  
Related examples in the same category
1.WebHeaderCollection.GetValues gets an array of header values stored in a header.
2.WebHeaderCollection.IsRestricted tells whether the specified HTTP header can be set for the request.
3.WebHeaderCollection.Remove removes the specified header from the collection.
4.WebHeaderCollection.Set sets the specified header to the specified value.
w___w_w._j__a___v_a__2__s__.c_om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.