ac1982

Hi I am a newbie in Visual Studio C# and I would like to ask you the following.
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:

Code Snippet

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




Re: Visual C# General Why I cannot see some of the methods in other classes?

Peter Ritchie

MaximumResponseHeadersLength is documented as not being supported by the .NET Compact Framework. If you're creating code for a device that property isn't available.






Re: Visual C# General Why I cannot see some of the methods in other classes?

ac1982

So is there a any other way to use that method





Re: Visual C# General Why I cannot see some of the methods in other classes?

Peter Ritchie

Not in the Compact Framework. You could try adding an httpWebRequest element to your app.config file. I don't know if that's supported by Compact Framework; the documentation doesn't say.






Re: Visual C# General Why I cannot see some of the methods in other classes?

ac1982

thanks for your help