We have an email confirmation page for registration which can be hit with a use-once link to activate the account.
The nature of the site is such that we can allow this link to log the user in automatically. This requirement is under review (at my request!).
The following situation is proving a little confusing:
- The user follows the confirmation link in their email
- This lands on the Confirm controller.
All things being good, the user is automatically logged in, using:
FormsAuth.SignIn(user.UserName,false);
The View is returned from the controller
The View uses a master page which contains a partial view that is the LogonUserControl.ascx component. Within the component, there is the following code (it comes straight out of the asp.net mvc project template):
if (Request.IsAuthenticated) { /*foo*/ }
When the page is rendered, Request.IsAuthenticated
is returning false despite signing the user in at the controller.
I'm wondering why this might be. Has the master already been written out by the time the FormsAuth.SignIn
method is called, or is using the Request object for this check wrong, because at the time the Request was received, it was indeed non-authenticated?
EDIT: It appears the default LogOn controller uses a redirect rather than returning a View. This would of course solve the problem, however I am interested in why the scenario above does not work.