18
13
|
I'm trying to pass JSON from jQuery to a .ASHX file. Example of the jQuery below:
How do I retrieve the JSON data in my .ASHX file? I have the method:
but I can't find the JSON values in the request.
Thanks in advance.
| ||
17
|
I kknow this is too old, but just for the record I'd like to add my 5 cents
You can read the json object on the server with this
| ||||
|
14
|
The following solution worked for me:
Client Side:
Server Side .ashx
| ||
2
|
If you send data to the server with respect of
$.ajax the data will not be converted to JSON data automatically (see http://stackoverflow.com/questions/2737525/how-do-i-build-a-json-object-to-send-to-an-ajax-webservice/2738086#2738086). So you can use contentType: "application/json; charset=utf-8" and dataType: "json" and stay don't convert data with JSON.stringify or$.toJSON. Instead of
(manual converting of data to JSON) you can try use
and get the data on the server side with
context.Request.QueryString["file"] andcontext.Request.QueryString["type"] constructs. If you do receive some problems with this way then you could try with
and usage
DataContractJsonSerializer on the server side. | ||||||||||
|
1
|
you have to defined the handler properties in web configuration file to handle the user defined extension request formats. here the user defined extension is ".api"
add verb="*" path="test.api" type="test" replace the url: "/test.ashx" to url: "/test.api" .
| ||
0
|
Try System.Web.Script.Serialization.JavaScriptSerializer - with casting to dictionary
| ||||||
|
0
|
if using $.ajax and using .ashx to get querystring ,dont set datatype
i get it work!
| |||
0
|
This works for calling web services. Not sure about .ASHX
|