WebRequest.get_headers()['Any Parameter'] doesn´t work

Last post 05-13-2008 1:57 AM by Elmar. 2 replies.

Sort Posts:

  • WebRequest.get_headers()['Any Parameter'] doesn´t work

    05-12-2008, 11:52 AM
    • Loading...
    • Elmar
    • Joined on 08-09-2006, 5:27 AM
    • Posts 33

    I have a Javascript function that basically updates a DOM Element´s content with data from the server. It works fine with Firefox but fails when used with Firefox or Safari. I think the reason for this is that Firefox sets more Parameters in the Request-Header (Accept, Accept-Charset for example) that makes the ASP.NET controls happy. So now I would like to add these parameters to the header myself. Unfortunatly Safari 3 and IE7 ignore these values. Am I missing something? 

    ...

    var wRequest =  new Sys.Net.WebRequest();   
        wRequest.set_httpVerb("GET"); 
        wRequest.set_url(url);
       
        wRequest.add_completed(
            function request_completed(result)
            {
                element.innnerHTML = result.get_responseData();
            }
        );  
       
        wRequest.get_headers()['Accept'] = 'text/xml; application/xml; application/xhtml+xml; text/html; text/plain;';
        wRequest.get_headers()['Accept-Charset'] = 'ISO-8859-1; utf-8;';

        wRequest.invoke();

    ... 

    Thanks,

    Elmar 

  • Re: WebRequest.get_headers()['Any Parameter'] doesn´t work

    05-12-2008, 12:26 PM

    What kind of data are you trying to retrieve? Is it just plain text? Maybe you can just try to package it as JSON, so it is also returned as a string. All the plumbings are done behind the scenes.

  • Re: WebRequest.get_headers()['Any Parameter'] doesn´t work

    05-13-2008, 1:57 AM
    Answer
    • Loading...
    • Elmar
    • Joined on 08-09-2006, 5:27 AM
    • Posts 33

    I actually got this part working. There is still something missing to make it work with IE and Safari but at least the Headers are added like one would expect.

    @ericpanorel: Actually I am converting this app back from ExtJS. ExtJS has a niffty little feature which simply let´s you update a DOM-Element with any content from another page. Something like Ext.get('someDomElem'').update('someURL');

    I tried to mimic this behavior but it is not as easy as it seemed in the first place. Because ASP.NET Ajax is still somehow limited in this area I might actually go with a simple Webrequest/JSON Response and deal with rendering content in the Script itself.

     Thanks,

    Elmar
     

Page 1 of 1 (3 items)