Silverlight 1.1's BrowserHttpWebRequest Bug
While playing with Astoria and Silverlight today, I found a problem with the WebRequest Headers. Luckily, Pablo Castro in the ADO.NET Team at Microsoft was there to set me straight. I wanted to warn everyone of this bug in case it bites you:
The BrowserHttpWebRequest.Accept property is improperly mapped to another HTTP header. So both of these examples won’t work the way you expect:
HttpWebRequest req = new BrowserHttpWebRequest(theUri); req.Accept = "application/json"; // Bugged req.Headers[HttpRequestHeader.Accept] = "application/json"; // Bugged
To get around this problem, use the weakly typed Header collection:
HttpWebRequest req = new BrowserHttpWebRequest(theUri); req.Headers["accept"] = "application/json"; // Works
Thanks again Pablo!