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.

RB.
  • 36,301
  • 12
  • 91
  • 131
user275157
  • 1,332
  • 4
  • 23
  • 45
  • 1
    I had a similar problem and could only solve by adding as a wcf header. Try this: [link](http://weblogs.asp.net/avnerk/archive/2006/04/26/Adding-custom-headers-to-every-WCF-call-_2D00_-a-solution.aspx) – Ortiga Apr 04 '11 at 14:15

0 Answers0