我想在IIS上使用WCF進行基本身份驗證。我如何滿足IIS基本身份驗證與WCF
我開發了一個RESTFul webservice並啓用了SSL。我通過user name
和password
通過
HttpContext.Current.Request.Headers["Authorization"],
我用這些信息來設置HttpContext.Current.User
到一個新的genericPrincipal()
。
最終屬性HttpContext.Current.User.Identity.IsAuthenticated
保持「真實」 但是,我收到的回覆是"401 Unauthorized"
。所以我的問題是,我如何滿足IIS基本認證?
的Web.Config
<?xml version="1.0" encoding="UTF-8"?>
<system.serviceModel>
<services>
<service name="Agfa.ChannelServiceRest.PrivateServices" behaviorConfiguration="PrivateBehaviors">
<endpoint contract="Agfa.ChannelServiceRest.IPrivateServices"
binding="webHttpBinding"
bindingConfiguration="Secure"
behaviorConfiguration="Web"
name="PrivateBehaviors" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="Secure">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="PrivateBehaviors">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>`
是的,我會的,我做了一個視頻與我的調試,並上傳到YouTube:https://www.youtube.com/watch?v=cqtWvM8l2Kg&feature=youtu.be該視頻演示了有關用戶信息的詳細調試請求,認證,e響應狀態。 – Lindemberg