(X) Hide this
    • Login
    • Join
      • Say No Bots Generate New Image
        By clicking 'Register' you accept the terms of use .
        Login with Facebook

Silverlight 1.1's BrowserHttpWebRequest Bug

(0 votes)
0 comments   /   aggregated from theADOguy on Dec 12, 2007   /   original article
Categories:   General

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!

Add Comment | digg this


Subscribe

Comments

No comments

Add Comment

Login to comment:
  *      *       
Login with Facebook