Cookies y AxWebBrowser

Discussion in 'ASP .Net Security' started by xx, Sep 8, 2004.

  1. xx

    xx Guest

    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.
     
    xx, Sep 8, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Madreza
    Replies:
    0
    Views:
    1,194
    Martin Madreza
    Nov 17, 2003
  2. Eric

    AxWebBrowser control

    Eric, Dec 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,651
  3. Thom Little

    AxWebBrowser Downloads

    Thom Little, Dec 26, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,222
    Steven Cheng[MSFT]
    Dec 28, 2005
  4. Nenefta
    Replies:
    0
    Views:
    485
    Nenefta
    Apr 27, 2006
  5. _Who
    Replies:
    7
    Views:
    2,687
Loading...

Share This Page