Unable to get Custom Error object with HTTP STATUS CODE 401 in WCF RRS feed

  • Question

  • I am returning a custom error object with http status code 401. On client side I get html content saying "401 - Unauthorized: Access is denied due to invalid credentials.".

    If I change it to 403 or 400 then it returns a valid custom error object. But the problem is only with 401.

    The same if I test it on my local machine then it returns a valid custom error object with 401 but if I publish it to production then it throws the html content as I mentioned above.

    Friday, August 1, 2014 7:46 AM


  • Hi,

    If your service is a WCF SOAP Service, then please try to enter your service address in the browser to see if it works.

    It will be better if you can tell us what kind of authentication that you use.

    When hosting in the IIS , we should enable the authentication and the SSL channel.

    Besides, please try to enable the WCF tracing to find the root cause.

    The following configuration taken from MSDN can be applied to enable tracing on your WCF Service.

          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
                 <add name="xml"/>
          <source name="System.ServiceModel.MessageLogging">
                <add name="xml"/>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
                <add name="xml"/>
            <add name="xml"
                 initializeData="Error.svclog" />

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, August 4, 2014 5:30 AM