Skip to main content

Unanswered Question HttpWebRequest - how to instantiate?RSS Feed

(0)

rstrahl
rstrahl

Member

Member

18 points

13 Posts

HttpWebRequest - how to instantiate?

So I'm tooling around the various CLR libraries and I'm trying to retrieve some generic HTTP content. I see the HttpWebRequest class, but I can't figure out how to get an instance. The class is abstract so I can't new it up, but the WebRequest.Create() that's usually used to create the instance doesn't exist either.

What am I missing here? How do I instantiate the HttpWebRequest?

Rick Strahl
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog

DotNetAddict
DotNetAd...

Member

Member

80 points

53 Posts

Re: HttpWebRequest - how to instantiate?

In the Silverlight 1.1 runtime, you need to use the BrowserWebRequest class, which is a slimmed down version of HttpWebRequest that utilizes the browser's network stack for safety reasons as well as to keep the size of the Silverlight download to a minimum.

The .NET Addict
http://dotnetaddict.dotnetdevelopersjournal.com

gstasa
gstasa

Member

Member

12 points

6 Posts

Re: HttpWebRequest - how to instantiate?

Correct, you need to instantiate BrowserHttpWebRequest for now (which only works against the origin host).

We are investigating ways to rationalize the networking classes further in a future milestone (probably by reintroducing a Create() method in HttpWebRequest).

This posting is provided "AS IS" with no warranties, and confers no rights.

rstrahl
rstrahl

Member

Member

18 points

13 Posts

Re: HttpWebRequest - how to instantiate?

Hmmm...  So why is the class there? Wink

Rick Strahl
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog

gstasa
gstasa

Member

Member

12 points

6 Posts

Re: HttpWebRequest - how to instantiate?

HttpWebRequest is an abstract class in Silverlight. BrowserHttpWebRequest contains the implementation.

This posting is provided "AS IS" with no warranties, and confers no rights.

rstrahl
rstrahl

Member

Member

18 points

13 Posts

Re: HttpWebRequest - how to instantiate?

Yup missed that as the BrowserHttpObject lives in a completely different assembly and Reflector didn't show any derived types.

 

Rick Strahl
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog

WilcoB
WilcoB

Member

Member

744 points

140 Posts

Re: HttpWebRequest - how to instantiate?

Yeah, this kind of sucks, but unfortunately we didn't have the time to do much about this (unless we'd introduce some crazy dependency). In the future we plan to hide BrowserHttpRequest entirely. That way it should be much more accessible and your code should be more portable (for what it's worth).

- Wilco Bauwer (MSFT) / http://www.wilcob.com
  • Unanswered Question
  • Answered Question
  • Announcement