Using WCF with custom authentication over SSL RRS feed

  • Question

  • I have implemented the above, however when I call the service with the right username and password, I get the following error:

    This is a 'System.ServiceModel.ProtocolException' that occurred in mscorlib.dll.

    This is my Web.config:

    <?xml version="1.0"?>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2"/>
            <binding name="SSL">
              <security mode="TransportWithMessageCredential">
                <message clientCredentialType="UserName"/>
          <service behaviorConfiguration="CustomValidation" name="WCFService.Service1">
            <endpoint address="" binding="wsHttpBinding" contract="WCFService.IService1" bindingConfiguration="SSL"/>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
            <behavior name="CustomValidation">
              <serviceMetadata httpsGetEnabled="true" />
              <serviceDebug httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFService.Verification, WCFService" />
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
        <modules runAllManagedModulesForAllRequests="true"/>
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
        <directoryBrowse enabled="false"/>

    This is my App.config:

    <?xml version="1.0" encoding="utf-8" ?>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
                    <binding name="WSHttpBinding_IService1">
                        <security mode="TransportWithMessageCredential">
                            <transport clientCredentialType="None" />
                            <message clientCredentialType="UserName" />
                <endpoint address="https://myService/Connor/WCFService/Service1.svc"
                    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
                    contract="ServiceReference1.IService1" name="WSHttpBinding_IService1" />

    Any help would be great

    Friday, April 15, 2016 12:37 PM


  • Hello,

    According to the error message, it seems that the client retrieves a html response from the web server which indicates that an error page has been served, but does not get the expected content type (text/xml; charset=utf-8) for the corresponding binding. Please try viewing the response by using the Fiddler.

    Then please type your WCF web service address in a web browser and check if it provides some more detailed error message.

    Besides, you can also try to turn on WCF tracing to see whether it can capture more detailed information at underlying channel level.

    For more information, please refer to the following similar thread:


    Best Regard,
    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, April 18, 2016 2:51 PM