Is it possible to format how an object is returned as JSON from a PageMethod? ie. removing the first "d" element from the data, without writing the JSON from scratch.
From:
{ "d": { "name": "bob", "email": "[email protected]" } }
To
{ "name": "bob", email: "[email protected]" }
The extra "d" parameter is added by the .NET framework as an added security measure against XSS attacks [source]. It's included when the "Content-Type" of the request specifies "application/json".
I think you can get the framework to exclude it (ie don't wrap the result in the "d") if you simply specifying the "Content-Type" of the request as something other than "application/json". Try removing that header from the request (if you can) and seeing what .NET returns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With