Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms Authentication - Cookie Created but not working

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
Hi Im having Problems with Forms Based Authentication

Below is my code that is called (after a database lookup)
- The Lookup is working

What happens (Ive confirmed this via a http proxy, and also via adding code to the Global.asax.cs file to look
at the cookies each time a page is called) - An authentication Cookie s is created, encrypted and saved to the cookie collection.
It is Output to the Hard Disk

When the page tries to redirect, it looks at the cookie. It sees the authorisation Cookie.
But it doesnt redirect, instead it shows the login page again.

so
1) Is there anyithing external that may be affecting this (Firewall is off)?
2) I must assume I have somehting awry in my settings, so what is it?

K

Code:
HttpContext context = HttpContext.Current;

string uName = selectCMD.Parameters["@output"].Value.ToString();
//The 10 Is the Inactive Timeout in Minutes
FormsAuthenticationTicket authTicket = new 
	FormsAuthenticationTicket(1,uName,DateTime.Now,DateTime.Now.AddMinutes(10),false,"");

//Encrypt the ticket
string eT = FormsAuthentication.Encrypt(authTicket);
//Create a Cookie and store the data
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
authCookie.Value = eT;

//Deny access to cookie in Scripts antiXss
authCookie.Path = FormsAuthentication.FormsCookiePath + "; HttpOnly";

context.Response.Cookies.Add(authCookie);

//authCookie.Expires = dt.AddHours(1);
//Response.Cookies.Add(authCookie);

//Redirect to Originally Requested Page
Label2.Text = (FormsAuthentication.GetRedirectUrl
	(uName,false));
Response.Redirect(FormsAuthentication.GetRedirectUrl
	(uName,false));

This is my Web.Config
Code:
<authentication mode="Forms" >
	<forms name=".ASPXAUTH" loginUrl="../login.aspx" slidingExpiration="true" protection="All" path = "/"/>
</authentication>

<!--  AUTHORIZATION 

-->

<authorization>
    <allow users="*" /> <!-- Allow all users To see the Main folder-->
</authorization>

K!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top