简体   繁体   中英

WCF disable anonymous authentication

I actually have a little problem with a WCF. Everything is ok except the fact that when I disable Aninymous Authentication on IIS, there are no results returned. I didn't wrote this code, it's from a co-worker who left the company. Here's the Web.Config form the WCF:

    <?xml version="1.0"?>
<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>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <uri>
    <schemeSettings>
      <clear/>
      <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
      <add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
    </schemeSettings>
  </uri>
  <system.net>
    <settings>
      <httpListener unescapeRequestUrl="false"/>
    </settings>
  </system.net>
  <system.web>
    <httpRuntime maxQueryStringLength="2048" maxUrlLength="4000" requestPathInvalidCharacters="" requestValidationMode="2.0" targetFramework="4.5"/>
    <pages validateRequest="false"/>
    <compilation targetFramework="4.5" debug="true"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="RestBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="MetadataBehavior">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="https" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MetadataBehavior" name="MyWCF.MyService">
        <!-- Configuration HTTPS-->

        <!--<endpoint address="SoapSecure" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyWCF.IMyService"/>
        <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="https" name="REST" contract="MyWCF.IMyService"/>-->

        <!-- Configuration HTTP-->
        <endpoint address="Soap" binding="basicHttpBinding" bindingConfiguration="" contract="MyWCF.IMyService"/>
        <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="MyWCF.IMyService"/>

      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true"/>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        Pour parcourir le répertoire racine de l'application Web lors du débogage, définissez la valeur ci-dessous sur true.
        Définissez-la sur false avant le déploiement pour ne pas divulguer d'informations du dossier de l'application Web.
      -->
    <directoryBrowse enabled="true"/>
    <!-- MK 27/10/2014: Access control same origin hotfix-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*"/>
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

Right now, the resolution of this problem is critical for the client, so I highly appreciate suggestions and any kind of help.

Thank you for your time

If you are disabling Anonymous Authentication you must also set the clientCredentialType as None

    <security mode="Transport">
        <transport clientCredentialType="None" />
    </security>

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