Posted on: 4/27/2011 9:51:30 AM | Views : 270

Hi, a problem: my website has login controls on the start page and when someone visits it, I want to show a message if he can login based on his Cookies settings in browser. Here comes a problem, because if I write a cookie for a test, then the page needs to be reloaded. So, I tried to test a proviously saved Session Variable in the OnLoggedIn event. This seems to do what I want while watching code executiuon in debugging mode, but then when ASP.NET can't write the authentification cookie the it renders page in teh state before the login attempt. So, I can't show my error message.
 
My code is:
 
Protected Sub OnLoggedIn(ByVal sender As Object, ByVal e As EventArgs)

If Roles.IsUserInRole(loginc.UserName, "user") Then
Response.Write("COOKIES DISABLED")
Response.Redirect("/test/default.aspx, False)
If Session("CookieTest") <> "This Cookie Equals My Cookie" Then lblCookieErr.Text = "ERROR"
.... Go to the complete details ...