[Mono-dev] Authentication with WebRequest?

Kornél Pál kornelpal at hotmail.com
Sat Aug 27 11:41:15 EDT 2005


>BTW, what's the difference between
> System.Net.WebRequest and HttpWebRequest?

WebRequest is an abstract base class. You should use WebRequest.Create() to
create a specific instance. It uses configuration to determine the type of
specific WebRequest class to use. This means that you can create your own
specific WebRequest type derived from WebRequest and register it in config
files (<webRequestModules> element).

If you specify http or https the created instance will be HttpWebRequest. So
do the following:

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://www.example.com/");

Kornél

----- Original Message -----
From: "knocte" <knocte at gmail.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Saturday, August 27, 2005 5:16 PM
Subject: Re: [Mono-dev] Authentication with WebRequest?


> Kornél Pál escribió:
>> If you don't want to do any special then you can simply use
>> HttpWebRequest.Credentials to sepcify user name and password.
>>
>> Kornél
>>
>> ----- Original Message -----
>> From: "Kornél Pál" <kornelpal at hotmail.com>
>> To: "knocte" <knocte at gmail.com>; <mono-devel-list at lists.ximian.com>
>> Sent: Friday, August 26, 2005 11:11 PM
>> Subject: Re: [Mono-dev] Authentication with WebRequest?
>>
>>
>>> You can use HttpWebRequest.Headers to specify HTTP headers.
>>>
>>> Note that you are actually talking about HTTP headers not TCP
>>> headers. TCP
>>> is a lower level layer than HTTP that you cannot manipulate using
>>> sockets.
>>>
>>> If you want to send the whole request as raw data you have to use
>>> sockets
>>> but you will have to process the response as well because you will
>>> get it
>>> as
>>> raw data. If you need the functionality of HTTP you can use
>>> HttpWebRequest
>>> as it exposes a lot of options through properties.
>>>
>>> Kornél
>
> Thanks Kornel I will try with HttpWebRequest. You are right about my
> TCP/HTTP confusion. I wanted to know just that, how to do this without
> dealing with sockets. BTW, what's the difference between
> System.Net.WebRequest and HttpWebRequest?
>
> Thanks again,
>
>    Andrew
>
> --
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list