Skip to main content
Microsoft Silverlight
Home Forums Silverlight Programming Programming with .NET - General HttpWebRequest - how to instantiate?
6 replies. Latest Post by WilcoB on May 5, 2007.
(0)
rstrahl
Member
18 points
13 Posts
05-04-2007 7:37 AM |
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?
DotNetAd...
80 points
53 Posts
05-04-2007 3:39 PM |
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.
gstasa
12 points
6 Posts
05-04-2007 5:14 PM |
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).
05-04-2007 5:52 PM |
Hmmm... So why is the class there?
05-04-2007 6:04 PM |
HttpWebRequest is an abstract class in Silverlight. BrowserHttpWebRequest contains the implementation.
05-04-2007 10:50 PM |
Yup missed that as the BrowserHttpObject lives in a completely different assembly and Reflector didn't show any derived types.
WilcoB
744 points
140 Posts
05-05-2007 12:49 AM |
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).