Call URLHelper.Redirect(url) Causes User to Get Logged Out

kentico guy asked on April 27, 2020 16:58

I am seeing an issue with Kentico where calling URLHelper.Redirect() is logging out the user. This is happening on a registration page. The new Kentico CMS_User object has already been created because if I don't call the Redirect method and just browse to another page, like the user profile page, I stay logged in.

Does anyone have any idea what might cause this method to log the user out?

Correct Answer

kentico guy answered on April 28, 2020 17:02

FYI, I was able to fix this by implementing

System.Web.Security.FormsAuthentication.SetAuthCookie(MembershipContext.AuthenticatedUser.UserName, false);

in the line before I call the Redirect() method.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on April 27, 2020 17:16

Hi,

Could you please provide some more info:

  • What version of Kentico do you use? Portal Engine vs MVC?
  • What do you use redirect for and when? Could you post your code here? Are you trying to redirect user to the page where he was before he clicked on "register" button or something like that?
1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 27, 2020 17:17

Are you using a web farm or do you have load balancer in front of the website? If so you need to set up Redis Cache or SQL Server database session. Any postback or redirect can cause the "authenticated" user to lose their session. By default the URLHelper.Redirect() does NOT log a user out.

2 votesVote for this answer Mark as a Correct answer

kentico guy answered on April 27, 2020 18:03

This is Kentico 12 portal engine. @Brendan thanks I'll check that out

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 28, 2020 18:23

Before implementing that, I'd suggest looking further into why your cookie is not persisiting. As I stated, the redirect DOES NOT cause a user to log out but a postback could cause issues with persisting the users session if you have a load balancer or a web farm set up. All your line of code is doing now is masking the underlying issue.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.