0

我的网站已启用Windows Authentication并且Anonymous Authentication数据库连接也使用 Windows 身份验证(基于用户登录)。

我打电话给AJAX-Enabled WCF Service它,它是匿名认证的。

在 IE 上一切正常。但是当我用 Firefox 打开它时,抛出异常:

用户“NT AUTHORITY\ANONYMOUS LOGON”登录失败。

在此处输入图像描述

网页配置

    <authentication mode="Windows">
        <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
    <identity impersonate="true" />
    <authorization>
        <deny users="?" />
    </authorization>
    .....
    .....
 <system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <!--<behavior name="metadataBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
    </behavior>-->
            <!-- Step 2. Add a new behavior below.-->
            <behavior name="metadataBehavior">
                <serviceMetadata  httpGetEnabled="true" httpsGetEnabled="false"/>
                <!-- Step 3. Add a <serviceDebug> element -->
                <serviceDebug  includeExceptionDetailInFaults="true" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                <serviceAuthorization/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="Mycompany.SGACostReduction.EditInitiativesAspNetAjaxBehavior">
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                <webHttp helpEnabled="true"/>
                <enableWebScript />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"  />
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint automaticFormatSelectionEnabled="false"
                              helpEnabled="true"
                              defaultOutgoingResponseFormat="Json"
                              name=""/>
        </webHttpEndpoint>
    </standardEndpoints>
    <services>
        <service name="Mycompany.SGACostReduction.EditInitiatives" behaviorConfiguration="metadataBehavior">
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:57771/EditInitiatives.svc" />
                </baseAddresses>
            </host>
            <endpoint address="" behaviorConfiguration="Mycompany.CostReduction.EditInitiativesAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Alixpartners.SGACostReduction.EditInitiatives"  >
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <bindings>
        <webHttpBinding>
            <binding name="webBinding">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
                </security>
            </binding>
        </webHttpBinding>
    </bindings>
</system.serviceModel>
4

1 回答 1

0

我认为这个页面可以帮助你

每当您尝试通过 javascript 或 jquery 调用跨域 WCF 服务时,它在不同浏览器中的行为会有所不同。当您想使用 jquery/javascript 或 ajax 对跨域 wcf 服务或普通服务执行“POST”或“GET”请求时,浏览器实际上会向您的 wcf 服务发送一个“OPTIONS”动词调用,该调用未在您的 wcf 方法中提及属性

http://www.dotnet-tricks.com/Tutorial/wcf/X8QN260412-Calling-Cross-Domain-WCF-Service-using-Jquery.html

于 2013-05-22T23:08:05.137 回答