我在 IIS7 中设置了启用 Windows 身份验证的网站。
我的服务中有 3 种方法,2 种方法需要 Windows 身份验证,1 种不需要。不使用的那个
[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
其他 2 个正在使用
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
我的 web.config 看起来像:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
当我运行尝试执行设置为允许的方法并且我没有传递任何凭据时,它会失败并出现未经授权的错误。我错过了什么?