Silverlight WebClient Accepts a title that is overwritten in Firefox 3

I have a Silverlight application that talks to a REST web service using the WebClient class. It works fine in IE 8 and Chrome 5, but the web service call fails in Firefox 3.

I narrowed down the problem: Firefox 3 changes the Accept header of my HTTP request. here is my simplified code:

// Use the ClientHttp stack.
WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);

// Call the web service.
var webClient = new WebClient();
webClient.Headers["Accept"] = "application/json";
webClient.DownloadStringAsync(someUrl);

Using Fiddler to examine pipe data, the request has a replaced header:

GET /1/36497f32-1acd-4f4e-a946-622b3f20dfa5/Content/GetAllTextContentsForUser/0 HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Host: localhost:88
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8

Pay attention to the second line “Accept” - it has been replaced by the text / html, xml and other formats. Not what I'm looking for - I absolutely need JSON to return.

Is there a way to prevent Firefox from changing my Accept header?

+3
1

, Accept . IE Chrome Accept "*/*" ( -). Firefox - , , , XML.

, Accept. Accept, ClientHttp.

+1

Source: https://habr.com/ru/post/1758062/


All Articles