none
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

Answers

  • 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.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    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
    Moderator