Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Forms Authentication Not Working

Reply
Thread Tools

Forms Authentication Not Working

 
 
Matt
Guest
Posts: n/a
 
      06-22-2005
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))

 
Reply With Quote
 
 
 
 
Tom.PesterDELETETHISSS@pandora.be
Guest
Posts: n/a
 
      06-22-2005
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))
>



 
Reply With Quote
 
 
 
 
Matt
Guest
Posts: n/a
 
      06-23-2005
Yes, it is still a problem, thanks.

Matt

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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))
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best practices for using forms authentication and security in a hosted env (was: Re: Using a Forms authentication in a shared hosting environment) JEFF ASP .Net 1 11-12-2007 07:00 PM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Logout not working - Forms Authentication domain wide cookie =?Utf-8?B?S3VsZGVlcA==?= ASP .Net 0 06-13-2005 06:31 PM
Forms Authentication not working on server Russell ASP .Net 6 03-24-2005 05:31 PM
Forms Authentication question: How to have some pages open and some requiring forms authentication Eric ASP .Net 2 02-13-2004 02:14 PM



Advertisments