问题
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.
来源:https://stackoverflow.com/questions/5539714/passing-a-cookie-to-a-wcf-service