将 cookie 传递给 wcf 服务
我有一堆 wcf webhttp (rest) 服务需要身份验证 cookie。问题是 - 如何将 formsauth 票证传递给 wcf 服务?流动身份验证适用于通过浏览器获取请求,效果很好(应该如此),但我不确定如何在使用 httpclient 或 webchannelfactory 的调用期间设置 cookie。至此,身份验证完成,cookie 可用。我不确定在通过 HttpClient 调用服务时在哪里插入 cookie。
HttpClient client = new HttpClient();
HttpContent content =
HttpContentExtensions.CreateDataContract<EmployeeData>(MyEmployee);
resp = client.Post("http://localhost/someservice", content);
我还尝试按照以下网址使用 webchannelfactory - http://zamd.net/2009/03/05/flowing-forms-authentication-cookie-to-wcf/
但是,var Identity = Thread.CurrentPrincipal.Identity as ClientFormsIdentity;
即使 Thread.CurrentPrincipal.Identity 是有效的 FormsIdentity,也会返回 null。任何建议都会非常有帮助。
I have a bunch of wcf webhttp (rest) services that expect an auth cookie. Question is - How do I pass the formsauth ticket to the wcf service? Flowing authentication works for get requests through the browsers just fine (as it should) but I am not sure how to set the cookie during my calls using httpclient or webchannelfactory. At this point the authentication is done and the cookie is available. I am not sure of where to insert the cookies while invoking the service through a HttpClient.
HttpClient client = new HttpClient();
HttpContent content =
HttpContentExtensions.CreateDataContract<EmployeeData>(MyEmployee);
resp = client.Post("http://localhost/someservice", content);
I also tried to use the webchannelfactory as per the following url - http://zamd.net/2009/03/05/flowing-forms-authentication-cookie-to-wcf/
However, var identity = Thread.CurrentPrincipal.Identity as ClientFormsIdentity;
returns a null even though the Thread.CurrentPrincipal.Identity is a valid FormsIdentity. Any suggestions would be greatly helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论