iis - Null JSON in getJSON response from IIS6, not IIS7? Using MVC2, jQuery, Ajax -
new here. i've searched quite bit working solution problem, though have found posts promising titles, none of solutions have worked.
i deploying mvc2 web app client's server.
i did development on win2k8 server, running win2k3 sever.
the app's purpose receive record id information http parameters, check in database status of given record or records, , return status information simple string such "completed" or "incomplete" in json format.
this getjson code works fine in development environment.
inexplicably me, on client's server, getjson request receives null response application.
there no cross-domain action afaik... result same client's server or machine via vpn.
in mvc model's json code, common solution people add "jsonrequestbehavior.allowget" attribute json result being returned. did long before trying deploy it, , said, has worked fine in dev environment.
using firebug, have watched same request url sent both local server , client server - response headers both servers same, response content server shown as:
{"result":"no data"}
which want.
there literally no content shown in response client's server..? request gets http 200 code , recorded success in reponse's status attribute.
the response header content type in both situations "application/json"
but wait, there more!
if manually enter request each server in firefox nav bar, , hit enter, in both cases responds with:
{"result":"no data"}
which want. why can result want mvc app on client's server only when hand-enter request url in firefox, not javascript code?
i have tried forcing different output content types ... using jquery ajaxsetup method...
$.ajaxsetup({ async: false, datatype: 'text' });
or
$.ajaxsetup({ async: false, datatype: 'html' });
and again wtih 'script', , 'json'. tried conversion options such 'text json' or 'html json' or 'json text' , forth.
some of posts i'm reading, , gut feeling, though, suggest problem not jquery code making request @ fault... don't see how same jquery request point different server running same app cause server send 'null' value.
by null, want clear... mean nothing sent. there no {} or {null} or sign of json... blank whiteness of non-existence :p
even if nobody knows answer, love input perhaps suggesting should focus sleuthing ... client or server?
if problem server, seems hard know mvc stuff running 100% on iis6 server, in general seems work. have different mvc app running on client server responds virtual paths, , runs same on dev machine.
i have found 1 thing ... request headers different? request headers sent iis7 setup include "x-requested-with: xmlhttprequest", "referrer" , , "cookie" field/value.
i guess lack of "x-requested-with: xmlhttprequest" in iis6 request headers clue, not see how same javascript code pointing @ different server can generate different request headers itself. how else being generated?
the javascript embedded in asp.net page, btw.
oooh.. frustration!
thanks input.
odd progress ... apparently there sort of issue iis6 handling query. although have not payed attention jsonp, post elsewhere suggested use "&callback=?" parameter @ end of .getjson request url force mode , worked problems getting data server. did that... , did work, sort of. proper {"result":"no data"} returned in response request... seems good. however, way jsonp callback works, generates own script calling , fetching , interpreting of incoming json. in case, interprets json need label not have, error thrown "invalid label" ... there must way hack things deliver json, whole required use of jsonp callbacks suggests server configuration wrong, right? or why work without jsonp iis7 , not iis6?
despite not liking callback jsonp solution, appears work ok. error still returned invalid label, not appear stop remaining javascript running... , application working iis6 now. have not tested fix of using callbacks , jsonp against iis7 yet, expect work enough.
here link discussion lead me current solution. still hope find more elegant solution, however.
are app extension mappings set correct?
follow this article running mvc2 on iis6 , ensure different configurations have been done, that's first step before going further , investigating specifics.
i'm inclined believe it's related http verbs.
Comments
Post a Comment