logo
VitNX3 Documentation

# DataFromSites.GetHeaderAndContent Method

Namespace: VitNX3.Functions.Web
Assembly: VitNX3 (in VitNX3.dll)
Gets the status header and content of site.
VB
C#
F#
C++
JScript
Copy

    public static string[] GetHeaderAndContent(
       string url,
       string userAgent
    )

    This language is not supported or no code example is available.

#### Parameters

url
  string

The url.

userAgent
  string

The UserAgent.

#### Return Value

string[]

An array of string (Header, Content).

Source code
VB
C#
F#
C++
JScript
Copy

    public static string[] GetHeaderAndContent(string url, string userAgent)
     {
         string[] data = { "Header", "Content" };
         HttpWebRequest wReq;
         HttpWebResponse wResp;
         Stream rStream;
         wReq = (HttpWebRequest)WebRequest.Create(url);
         wReq.KeepAlive = false;
         wReq.Referer = url;
         wReq.UserAgent = userAgent;
         wResp = (HttpWebResponse)wReq.GetResponse();
         data[0] = wResp.Headers.ToString();
         rStream = wResp.GetResponseStream();
         int bufCount = 0;
         byte[] byteBuf = new byte[1024];
         do
         {
             bufCount = rStream.Read(byteBuf, 0, byteBuf.Length);
             if (bufCount != 0)
                 data[1] += Encoding.ASCII.GetString(byteBuf, 0, bufCount);
         }
         while (bufCount > 0);
         return data;
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
DataFromSites Class
VitNX3.Functions.Web Namespace