Correct way to Redirect for Login

  • Thread starter Thread starter LK
  • Start date Start date
L

LK

Hi,

I have a UserControl which is embedded onto the header of all my web pages.
When I click Signin, I want the user control to record the page I was on
(the full url if possible), and then redirect to the signin page. When the
user has signed in, I want to redirect back to the originating page. I
cannot seem to get this working, short of frigging the url, and wondered if
there is an easier way?

Thanks

LK.
 
Hello LK,

If you are using forms authentication you can use something like

FormsAuthentication.RedirectToLoginPath();

and .net will handle all the refering URL crap.

Martin.
 
Karl and Martin,

Thanks for your replies - dont know how I missed the FormsAuthentication
call! Anyway, when I call FormsAuthentication.RedirectFromLoginPage I am
redirected to the Default webpage, and not the page I was actually viewing.
In my test, I was viewing a product detail page I have for sale, and
expected to go back to it if I choose to sign in on this page using the link
in the header. But instead I returned to the home page, which is not what I
am after. Is there anything else I need to do?

Thanks again!
 
LK:
Are you simply using RedirectFromLoginPage or are you using
formsauthentication as your authentication mechanism throughout the site?
(ie, specifying FormsAuthentication in the web.config and denying anonymous
users?)

Karl
 
Back
Top