HttpContext.Current.User.Identity.IsAuthenticated is false after Response.Redirect
Hi,
We are working on a solution where we are using custom pages that requires User to be logged in. To test this scenario, we simply created a login page (login.aspx) with ASP.Net Login Control and another page (securepage.aspx) which should show only if the user is logged in.
Everything works fine till be do a Response.Redirect("securepage.aspx") i.e. HttpContext.Current.User.Identity.IsAuthenticated is true till we call Response.Redirect.
However, when we check HttpContext.Current.User.Identity.IsAuthenticated on Page_Load of securepage.aspx it is returning false.
Currently the code is very simple and is as follows:
//** login.aspx **
protected
void
Login1_Authenticate(
object
sender, AuthenticateEventArgs e)
UserManager userManager = UserManager.GetManager();
if
(userManager.ValidateUser(Login1.UserName, Login1.Password))
e.Authenticated =
true
;
protected
void
Login1_LoggedIn(
object
sender, EventArgs e)
UserManager userManager = UserManager.GetManager();
Telerik.Sitefinity.Security.Model.User userToAuthenticate =
null
;
UserLoggingReason userLoggingReason = SecurityManager.AuthenticateUser(userManager.Provider.Name, Login1.UserName, Login1.Password,
false
,
out
userToAuthenticate);
//bool isLoggedIn = HttpContext.Current.User.Identity.IsAuthenticated; <---- returns true
HttpContext.Current.Response.Redirect(
"securepage.aspx"
);
protected
void
Page_Load(
object
sender, EventArgs e)
bool
isLoggedIn = HttpContext.Current.User.Identity.IsAuthenticated;
//<--- returns false
Hello Santanu,
Can you give us more details on your scenario? Are you using claims based authentication or forms based?
Greetings,Hi Jen,
By the time your reply came in, we have been able to solve the problem. It was indeed a problem of Authentication type. We could solve it by selecting 'Form Based Authentication' in Sitefinity. By default 'Claim Based Authentication' was selected.
Thanks for your reply anyways.
Santanu
Hello Jen,
Can you please explain with a claims based authentication scenario?
Thanks in advance
Hi Jen
Can I also please put in a call for an explanation/demo code for a claims based authentication scenario as we are having a very similar problem.