Passing a cookie to a wcf service
Asked Answered
M

0

1

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.

Midstream answered 4/4, 2011 at 14:10 Comment(1)
I had a similar problem and could only solve by adding as a wcf header. Try this: linkHeriot

© 2022 - 2024 — McMap. All rights reserved.