Does System.ServiceModel.ProtocolException always

2019-08-13 18:58发布

Thats my question, I'm catching a few WCF exceptions on my client and the ProtocolException always has html code in its message.
Could I assume that will happen every time? For what I see the real good message comes in the inner exception, could I just discard the ProtocolException message and show the user the message from the inner exception?

1条回答
何必那么认真
2楼-- · 2019-08-13 19:22

No, it doesn't always contain HTML in the message. Generally if there is HTML it's because the server your talking with (or through) hasn't understood (or blocked) the request, and has replied with an HTML explanation as to why. The message is useful for figuring out the problem.

Unfortunately that isn't the only time you'll see ProtocolExceptions, so you can't assume it will always contain HTML.

查看更多
登录 后发表回答