Cookies y AxWebBrowser

X

xx

My problem could no be exactly ASP.NET, but I think this is the best place to
comment it.

I have an ASP.NET page with "Forms" athentication (not Windows).
(this page was already set in our web site, and must be continue as now for
other webclients to use it)

But now, I need an additional WinForms (C#) application, with an ActiveX
AxWebBrowser control to display it.
However, this new win client shouldn't start any new session via Forms
authentication, because it's a already authenticated via Windows.

This is imposible without the correct cookie, isn´t?.
For this reason I've prepared a web service to be invoke by the win client
and get the cookie.


[WebMethod]
public bool Login (string user, string pwd)
{
bool isPersistable = true;
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket (1,
user, DateTime.Now, DateTime.Now.AddMonths(2), isPersistable, string.Empty);
string encryptedTicket = FormsAuthentication.Encrypt (authTicket);
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
if (isPersistable)
{
authCookie.Expires = authTicket.Expiration;
}
HttpContext context = this.Context;
context.Response.Cookies.Add(authCookie);
return true;
}

At the client I do the next:
if (myService.Login (user,pwd))
System.Net.Cookie cookie = myService.CookieContainer.GetCookies(new
System.Uri (myService.Url))cookieColl[0]


Until here, ALMOST EVERYTHING go well: I have the cookie at memory, but not
as a file in hard-disk.
Don´t worry, I think, It can be pass by code to the Navigate2 (...,headers)
of the browser control

And here is the second problem: There is no way to pass it in the 'headers'

strHeaders = "Cookie: " + cookie.Name + "=" + cookie.Value + "\r\n";
strHeaders += "Content-Type: application/x-www-form-urlencoded\r\n";

Because 'headers' parameter is an additional headers collection, so if there
was already another previous cookie in it, the mine will be ignored, Won't it?

I´ve checked with a HttpTracer. Because there was this cookie
Cookie: ASP.NET_SessionId=s1pnuh45i3h2dh55rto23bn1
My cookie is not passed.

¿Any idea?????

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top