문제

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

올바른 솔루션이 없습니다

다른 팁

The behavior has changed, because Microsoft switched from using the DataContractJsonSerializer to Json.NET (NewtonSoft).

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"
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top