FormsAuthentication and GetRedirectUrl

J

Joe

Hello,

I'm using FormsAuthentication for a single page. If the user tries to go
direct to the page they are prompted to login. This all works fine. But if
the user doesn't have a user account and clicks the Create user account link
the GetRedirectUrl no longer has the original page they were going to.
Instead it has the default from the web.config.

Is there any way to preserve the original URL past the login page?

Ideally if the user clicks to create account, I want to transfer them to the
page to create it. Once done I want to direct them to their original page
which will prompt them to login.

I hope this makes sense.

Thanks,
Joe
 
S

Steven Cheng[MSFT]

Hi Joe,

As for the Forms Authentication url redirction problem you mentioned, I
understand what you want to do and the difficulty here is
FormsAuthentication will only append originalUrl in querystring when the
redirection is caused by Unauthorization. For the "create new account"
case, it is not redirected by unauthorization, but by the user who click
the link, then the ASP.NET will not provide such url.

Currently, my suggestion is to manually keep such a url in session. for
example, in the page where you provide the "Create User account" link, you
can add the following code logic:

** you should modify the link to the create account page, append the
original url to the querystring of this link's url

** in the create account page, you can get the original url from
querystring and store it into session

** After user finished creating account, you can check the session
variable, if there is url exists, redirect to the url (if not exists due to
some reason, redirect the default location)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
J

Joe

Hi Steven,

I sort of thought that would be the case so I did manually track the url for
redirection after the user logs in.

Thanks,
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top