I ve created two different projects the first is a Device Application and the second is a Console Application.
I ve used the following code in Console Application:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
public class Test
{
// Specify the URL to receive the request.
public static void Main(string[] args)
{
Uri myUri = new Uri("http://www.contoso.com");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myUri);
// Set some reasonable limits on resources used by this request
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
// Set credentials to use for this request.
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine("Content length is {0}", response.ContentLength);
Console.WriteLine("Content type is {0}", response.ContentType);
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
Console.WriteLine("Response stream received.");
Console.WriteLine(readStream.ReadToEnd());
response.Close();
readStream.Close();
}
}
When I tried to do the same for the Device Application I couldn't use: request.MaximumResponseHeadersLength = 4; I got the following error:
Error 1 'System.Net.HttpWebRequest' does not contain a definition for 'MaximumResponseHeadersLength'
I ve checked Object Browser: System.Net.HttpWebRequest.MaximumResponseHeadersLength and the method exists.
Can someone explains me what I did wrong Why I cannot use this method
Thanks