WebProtocolExceptions being translated into HTML 200 OK responses

Last post 07-07-2009 5:37 PM by Amit Sharma. 2 replies.

Sort Posts:

  • WebProtocolExceptions being translated into HTML 200 OK responses

    06-29-2009, 11:38 AM
    • Member
      point Member
    • aehso
    • Member since 06-29-2009, 3:33 PM
    • Posts 1

    (Similar problem to http://forums.asp.net/p/1416605/3125648.aspx but no solution advised there)

    Hi,

     I have a RESTful WCF service that is run via a custom ServiceHost (which extends WebServiceHost2 from the starter kit) that is constructed by my own factor - I need this arrangement in order to initialize a Unity container when my service is starting up. 

     It all works fine except for throwing WebProtocolExceptions from within my service impl.  Whenever I do this, IIS (6) insists on converting the response status to 200 OK and it embeds the real response code in a HTML response: e.g.

    <html version="-//W3C//DTD XHTML 2.0//EN" xml:lang="en" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><HEAD><TITLE>Request Error</TITLE></HEAD><BODY><DIV id="content"><P class="heading1"><B>Error Status Code:</B> 'Unauthorized'</P><P><B>Details: </B>Unauthorized</P><!-- Padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--></DIV></BODY></html>

    I need to disable this behavior - can anyone advise on the magic property on the service host (or via web.config) that will force IIS to return the correct response status code (and do away with this HTML conversion of the body)?

  • Re: WebProtocolExceptions being translated into HTML 200 OK responses

    07-06-2009, 1:03 PM
    • Member
      28 point Member
    • Amit Sharma
    • Member since 12-30-2008, 12:01 AM
    • Posts 14

    please post the contents of your .svc file. 

    Amit Sharma
  • Re: WebProtocolExceptions being translated into HTML 200 OK responses

    07-07-2009, 5:37 PM
    • Member
      28 point Member
    • Amit Sharma
    • Member since 12-30-2008, 12:01 AM
    • Posts 14

    this is already resolved here --> http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/e1db4708-8638-42fb-9c32-761bae702b13

    Amit Sharma
Page 1 of 1 (3 items)