[OPEN] [#522] [1.6] Content-Type in DirectEvent response

  1. #1

    [OPEN] [#522] [1.6] Content-Type in DirectEvent response

    I'm using version 1.6 (when my svn access will be activated I'll start the transition to 1.7), and I'm having a problem due to the content type of direct events' response. The problem is the same as reported here http://forums.ext.net/showthread.php...Type-Mis-Match.
    I'm using a proxy that needs to modify html pages, and it modifies responses containing a json string because the content type is set to "text/html". Direct methods seem to work correctly, as the content type is set to "application/json".
    Is there some configuration/workaround? I could write an HTTP filter to modify the response, but it would not be the best way.
    Last edited by Daniil; Jul 08, 2014 at 4:15 PM. Reason: [OPEN] [#522]
  2. #2
    Hi @moldeveloper,

    I am not sure we can change "text/html".

    I'm using a proxy that needs to modify html pages, and it modifies responses containing a json string because the content type is set to "text/html".
    There is an "X-Ext.Net" ("X-Ext-Net" in SVN sources) header we send with each Ext.NET AJAX request. If you can analyze it and decide the response should be changed or no.

    Direct methods seem to work correctly, as the content type is set to "application/json".
    I guess only with "json: true" setting?
  3. #3
    I am not sure we can change "text/html".
    Why? I think it's a bug, the content in this case is never an HTML stream but a JSON serialization.

    There is an "X-Ext.Net" ("X-Ext-Net" in SVN sources) header we send with each Ext.NET AJAX request. If you can analyze it and decide the response should be changed or no.
    Ok, I'm going to try, I hope not to put excessive overhead on every request.

    I guess only with "json: true" setting?
    Yes. I removed the setting but I got a server error 500 (don't know why).
  4. #4
    Well, it is hardly a bug. At least, it is very controversial.

    First of all, we deal with a DirectEvent's response on client side and parse it flawlessly.

    Moreover, a response of a DirectEvent might be a real "text/html" in the case of downloading. It can be just a piece of text, not a JSON, if it is a DirectEvent for a <Loader> with Mode="Scripts" or "Html". So, we cannot set "application/json" for any DirectEvent. Respectively, it is not a way to distinguish a DirectEvent from other requests. As I said earlier, there is a label of Ext.NET DirectEvent in the headers which you can analyze to distinguish a DirectEvent request from others.

    One more point, that legacy browsers might have problems with "application/json". The legacy browsers are still supported.
    http://www.entwicklungsgedanken.de/2...plicationjson/

    Please share what you think about the thoughts above.
  5. #5
    Hi Daniil,

    I agree that not every DirectEvent response should use "application/json". But I think that when (and only when) the stream is a JSON serialization, the Content-Type should match. As for old browser compatibility, you could add a configuration flag or check server-side the browser version and act accordingly.
    I looked the sources, is it possible to know when JSON is used inside the Flush() method of the AjaxRequestFilter class?
    I made an HttpModule to change the Content-Type and it seems to work, but I would like not to use it.
  6. #6
    Thank you for the suggestion. We will re-consider that for Ext.NET v3.
    https://github.com/extnet/Ext.NET/issues/522

Similar Threads

  1. Replies: 1
    Last Post: Jul 01, 2014, 1:45 PM
  2. Replies: 6
    Last Post: Jan 13, 2014, 11:47 AM
  3. Problem DirecEvent Before/Click
    By DanielU in forum 1.x Help
    Replies: 3
    Last Post: Jan 14, 2013, 9:35 AM
  4. DirecEvent Return NORESPONSE on Error
    By inaltec in forum 1.x Help
    Replies: 4
    Last Post: Nov 19, 2012, 2:45 PM
  5. Replies: 0
    Last Post: Aug 05, 2012, 10:46 AM

Tags for this Thread

Posting Permissions