HttpContext.Current.User.Identity.IsAuthenticated is false a

Posted by Community Admin on 04-Aug-2018 06:57

HttpContext.Current.User.Identity.IsAuthenticated is false after Response.Redirect

All Replies

Posted by Community Admin on 03-Apr-2012 00:00

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

 


//**securepage.aspx **
protected void Page_Load(object sender, EventArgs e)
 
    bool isLoggedIn = HttpContext.Current.User.Identity.IsAuthenticated;  //<--- returns false
 

As I read somewhere in the forum that SecurityManager.AuthenticateUser method will automatically set the required cookies etc, which means the above should work, but looks like we are doing something wrong (or something that we are not doing) due to which it is not working.

Please Help!!

Santanu Biswas

Posted by Community Admin on 05-Apr-2012 00:00

Hello Santanu,

Can you give us more details on your scenario? Are you using claims based authentication or forms based?

Greetings,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Apr-2012 00:00

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

Posted by Community Admin on 11-Apr-2012 00:00

Hello Jen,

Can you please explain with a claims based authentication scenario?

Thanks in advance

Posted by Community Admin on 07-Sep-2012 00:00

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.

Regards,
David Bigg

This thread is closed