The behavior has changed, because Microsoft switched from using the DataContractJsonSerializer
to Json.NET (NewtonSoft).
JSON response doesn't contain "d" Anymore!!! asp.net 4.5
-
24-06-2022 - |
Question
I have a question, we are converting asp.net 3.5 to asp.net 4.5 during this - we had many problems but now... we finally got it too load up now i am having strange behaviour in JSON responses from services they don't contain "d" anymore!
{d: "response from server"}
its now
{"response from server"}
which breaks javascript code for callback any idea? or explanation
No correct solution
OTHER TIPS
If you want to name your variable when you return a result, you need to serialize it properly.
If you return a string you will get { "your string" } but if you return an object (or in 4.5 a Task of type dynamic or better yet Task of type 'Your Object') you will get your fully serialized object
return new {
result = "here is your result",
code = "here is your code"
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow