Ive been trying to make a forms authentication work for 2 days now. There seems to be a problem with writting the forms authenticate cookie on my firefox browser (it works on ie6).
my login.aspx.cs code is:
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie authCookie1 = new HttpCookie("aaaa1", "aaa");
Response.AppendCookie(authCookie1);
if (IsPostBack)
{
String nextPage = null;
filecloudTableAdapters.UsersTableAdapter checkUserAdapter = new filecloudTableAdapters.UsersTableAdapter();
filecloud.UsersDataTable checkUser = checkUserAdapter.CheckIfUserExists(username_textbox.Text, password_textbox.Text);
if (checkUser.Rows.Count > 0)
{
filecloud.UsersRow userRow = (filecloud.UsersRow)checkUser.Rows[0];
FormsAuthentication.SetAuthCookie(userRow.user_name, true);
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, userRow.user_name, DateTime.Now, DateTime.Now.AddMinutes(30), RememberMe.Checked, "aaa");
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.AppendCookie(authCookie);
HttpCookie authCookie2 = new HttpCookie("aaaa2", "aaa");
Response.AppendCookie(authCookie2);
if (Request.QueryString["ReturnUrl"] != null)
{
nextPage = Request.QueryString["ReturnUrl"];
}
else
{
nextPage = "Default.aspx";
}
Response.Redirect(nextPage, true);
}
else
{
error_label.Text = "Puf!";
}
}
}
Now the first cookie up there before the postback is working. The second one wont write. I tried with SetAuthCookie and it didnt work at all (not even before the postback)
My web.config auth is as such:
<authentication mode="Forms">
<forms name="filecloud"
loginUrl="login.aspx" cookieless="AutoDetect" domain="localhost"
protection="All"
enableCrossAppRedirects="true"
timeout="30"
path="/">
</forms>
</authentication>
<authorization>
<deny users="?" />
<!-- Deny anonymous user -->
<allow users="*" />
<!-- Allow all authenticated users -->
</authorization>
The weird thing is that last night the whole thing was working.
does anyone have any ideas?