Last post Aug 18, 2009 01:55 AM by tvish
Aug 08, 2009 04:12 AM|MWeber|LINK
I have asked this before and didnt really get any help. I think perhaps my question was not clear. Here is it is very simple.
When unhandled exception occur (such as typo in endpoint name or XML) the WCF service returns a very ugly "Internal Server Error". It is pretty much useless for everyone.
With ServiceHost you can easily override IErrorHandler and trap all unhandled exceptions, then form your own response. However, with the introduction of WebServiceHost2 and WebExceptionProtocol you can no longer override IErrorhandler.
Does anyone have a way to trap unhandled exceptions with WebServiceHost2? If so can you please help? Thank you.
Aug 10, 2009 10:56 AM|jez9999|LINK
I'm gonna echo this question. If the writers of WebServiceHost2 overlooked the ability to override Exception handling, then that's quite a depression omission.
Aug 18, 2009 01:55 AM|tvish|LINK
You can subclass WebHttpBehavior2 and override AddServerErrorHandlers to plug in your own error handler. You would also need to derive from WebServiceHost2 and replace WebHttpBehavior2 with your own behavior. We'll investigate making this simpler in 4.0.