开发者

How do I send errors by throwing an exception in a json asmx client/server call?

I have an asmx web service that can be called using either SOAP or JSON. When I throw custom exceptions in a method (for instance for telling user he/she sent an invalid password) they are properly sent to client if it's a SOAP call. But if it is a JSON call it seems like it will always be a standard 500 Internal Server Error - n开发者_StackOverflow社区o matter what exception I am throwing.

How do I send proper error messages if user calls service using JSON?


I had a similar issue that was solved by adding the following to my web config

<system.web.extensions>
<scripting>
<webServices>
    <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
</webServices>
</scripting>

My custom exceptions are now returned as expected regardless of consumer.

Rgds AJ

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜