简体   繁体   中英

WCF Custom Error Page when self-hosting service (Without IIS)

I have a self-hosted WCF service that exposes only one WebInvoked operation with address and parameters as such:

www.myserver.com/myservice/SayHello?LuckeyNumber=3  (where LuckeyNumber : int)

Now, when someone is trying to access this address but with LuckeyNumber=EvilInput I get a WCF error page that I would like to replace with a page (Similar to the Twitter Fail Whale).

  1. How to replace this page?
  2. Can I replace the page also for 404s, 405s and etc?

Thanks!

For self-hosted WCF, if you hosting REST services you can add WebHttpBehavior to get a HELP page, but you surely can send Fault Exception details (not the entire html page) in the response of your service.

The application consuming these services should take care of displaying the fault details in a fancy error page.

You should always leave that decision on the consumer (not at service layer) to mask this data and display/log it as they need it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM