Forms Authentication Not Working

Discussion in 'ASP .Net' started by Matt, Jun 22, 2005.

  1. Matt

    Matt Guest

    I have something weird hapenning on my forms authentication, which to me
    seems to be straight out of the MS help files

    After the user logs in, they shoul dbe redirected to the resource they were
    trying to reach. But all that happens is that they are reirected back to the
    login page.

    From trial and error, I believe that the cookie is never being created and
    written.

    In case this is an issue, my Browser has minimum security, and allows
    cookies, and my firewall is turned off.

    So, is the code below sufficient for my task, and if so, any more ideas as
    to why it might not be working?

    Matt

    Code:
    FormsAuthenticationTicket authTicket = new
    
    FormsAuthenticationTicket(selectCMD.Parameters["@output"].Value.ToString(),f
    alse,10);
    
    //Encrypt the ticket
    string eT = FormsAuthentication.Encrypt(authTicket);
    //Create a Cookie and store the data
    HttpCookie authCookie = new
    HttpCookie(FormsAuthentication.FormsCookieName,eT);
    DateTime dt = DateTime.Now;
    authCookie.Expires = dt.AddHours(1);
    Response.Cookies.Add(authCookie);
    
    //Redirect to Originally Requested Page
    Label2.Text = (FormsAuthentication.GetRedirectUrl
    (selectCMD.Parameters["@output"].Value.ToString(),false));
    Response.Redirect(FormsAuthentication.GetRedirectUrl
    (selectCMD.Parameters["@output"].Value.ToString(),false))
    
    Matt, Jun 22, 2005
    #1
    1. Advertising

  2. Matt

    Guest

    Hi Matt,

    I will try your code later this evening. Is it still a problem?

    Cheers,
    Tom Pester

    > I have something weird hapenning on my forms authentication, which to
    > me seems to be straight out of the MS help files
    >
    > After the user logs in, they shoul dbe redirected to the resource they
    > were trying to reach. But all that happens is that they are reirected
    > back to the login page.
    >
    > From trial and error, I believe that the cookie is never being created
    > and written.
    >
    > In case this is an issue, my Browser has minimum security, and allows
    > cookies, and my firewall is turned off.
    >
    > So, is the code below sufficient for my task, and if so, any more
    > ideas as to why it might not be working?
    >
    > Matt
    >
    >
    Code:
    > FormsAuthenticationTicket authTicket = new
    > FormsAuthenticationTicket(selectCMD.Parameters["@output"].Value.ToStri
    > ng(),f alse,10);
    >
    > //Encrypt the ticket
    > string eT = FormsAuthentication.Encrypt(authTicket);
    > //Create a Cookie and store the data
    > HttpCookie authCookie = new
    > HttpCookie(FormsAuthentication.FormsCookieName,eT);
    > DateTime dt = DateTime.Now;
    > authCookie.Expires = dt.AddHours(1);
    > Response.Cookies.Add(authCookie);
    > //Redirect to Originally Requested Page
    > Label2.Text = (FormsAuthentication.GetRedirectUrl
    > (selectCMD.Parameters["@output"].Value.ToString(),false));
    > Response.Redirect(FormsAuthentication.GetRedirectUrl
    > (selectCMD.Parameters["@output"].Value.ToString(),false))
    > 
    , Jun 22, 2005
    #2
    1. Advertising

  3. Matt

    Matt Guest

    Yes, it is still a problem, thanks.

    Matt

    <> wrote in message
    news:...
    > Hi Matt,
    >
    > I will try your code later this evening. Is it still a problem?
    >
    > Cheers,
    > Tom Pester
    >
    > > I have something weird hapenning on my forms authentication, which to
    > > me seems to be straight out of the MS help files
    > >
    > > After the user logs in, they shoul dbe redirected to the resource they
    > > were trying to reach. But all that happens is that they are reirected
    > > back to the login page.
    > >
    > > From trial and error, I believe that the cookie is never being created
    > > and written.
    > >
    > > In case this is an issue, my Browser has minimum security, and allows
    > > cookies, and my firewall is turned off.
    > >
    > > So, is the code below sufficient for my task, and if so, any more
    > > ideas as to why it might not be working?
    > >
    > > Matt
    > >
    > >
    Code:
    > > FormsAuthenticationTicket authTicket = new
    > > FormsAuthenticationTicket(selectCMD.Parameters["@output"].Value.ToStri
    > > ng(),f alse,10);
    > >
    > > //Encrypt the ticket
    > > string eT = FormsAuthentication.Encrypt(authTicket);
    > > //Create a Cookie and store the data
    > > HttpCookie authCookie = new
    > > HttpCookie(FormsAuthentication.FormsCookieName,eT);
    > > DateTime dt = DateTime.Now;
    > > authCookie.Expires = dt.AddHours(1);
    > > Response.Cookies.Add(authCookie);
    > > //Redirect to Originally Requested Page
    > > Label2.Text = (FormsAuthentication.GetRedirectUrl
    > > (selectCMD.Parameters["@output"].Value.ToString(),false));
    > > Response.Redirect(FormsAuthentication.GetRedirectUrl
    > > (selectCMD.Parameters["@output"].Value.ToString(),false))
    > > 

    >
    >
    Matt, Jun 23, 2005
    #3
    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. Eric
    Replies:
    2
    Views:
    1,458
    Tommy
    Feb 13, 2004
  2. Russell
    Replies:
    6
    Views:
    599
    russell mccloy
    Mar 24, 2005
  3. =?Utf-8?B?S3VsZGVlcA==?=

    Logout not working - Forms Authentication domain wide cookie

    =?Utf-8?B?S3VsZGVlcA==?=, Jun 13, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    634
    =?Utf-8?B?S3VsZGVlcA==?=
    Jun 13, 2005
  4. Replies:
    3
    Views:
    607
    JeffP@Work
    Sep 13, 2006
  5. Eric
    Replies:
    2
    Views:
    500
Loading...

Share This Page