我有麻烦获取身份验证Cookie放入客户端Windows服务的HTTP请求头中,使用“会话”使用IIS中托管的WCF服务。客户端应用程序使用表单身份验证来访问WCF服务。验证成功后,我捕获HTTP响应头包含.ASPXAUTH的Set-Cookie和ASP.NET_SessionId的Set-Cookie。我将这些cookie添加到HTTP请求标头中,以获取对WCF服务的所有后续请求。使用Fiddler调试工具,我可以看到对于WCF服务的每个请求,都会发送两个HTTP请求。第一个HTTP请求标头不包含cookie,但第二个HTTP请求包含。当我通过将web.config的Authorization部分设置为'deny users =“?''来保护服务时,头中没有cookie的第一个HTTP请求会强制'重定向'返回登录,从而阻止访问服务。我认为第一个要求与使用“会话”有关。当我在我的WCF服务中禁用“会话”时,每个WCF调用只能获得一个HTTP请求,Cookie位于标题中。如何获得发送到我的WCF服务的所有HTTP请求标头中的身份验证返回的Cookie? 任何有关这个问题的帮助将非常感激。如何将所有后续HTTP请求标头中的身份验证Cookie传递给WCF服务?
我已经包含了客户端的绑定。
<customBinding>
<binding name="CustomBinding_IMySyncService" receiveTimeout="00:01:00"
sendTimeout="00:01:00">
<reliableSession acknowledgementInterval="00:00:30"
inactivityTimeout="00:03:00"
maxTransferWindowSize="4096" />
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
<binding name="CustomBinding_AuthenticationService">
<binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
您如何将cookies附加到请求中。您是使用CookieContainer方法,还是设置绑定,如' ' –
Chandermani
2011-06-10 05:01:24