Forms Authentication Not Working

M

Matt

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))
 
T

Tom.PesterDELETETHISSS

Hi Matt,

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

Cheers,
Tom Pester
 
M

Matt

Yes, it is still a problem, thanks.

Matt

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))
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top