FormsAuthentication and GetRedirectUrl

Discussion in 'ASP .Net' started by Joe, Feb 12, 2008.

  1. Joe

    Joe Guest

    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
    Joe, Feb 12, 2008
    #1
    1. Advertising

  2. 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.
    --------------------
    >From: "Joe" <>
    >Subject: FormsAuthentication and GetRedirectUrl
    >Date: Tue, 12 Feb 2008 12:40:33 -0500


    >
    >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
    >
    >
    >
    Steven Cheng[MSFT], Feb 13, 2008
    #2
    1. Advertising

  3. Joe

    Joe Guest

    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

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > 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.
    > --------------------
    >>From: "Joe" <>
    >>Subject: FormsAuthentication and GetRedirectUrl
    >>Date: Tue, 12 Feb 2008 12:40:33 -0500

    >
    >>
    >>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
    >>
    >>
    >>

    >
    Joe, Feb 14, 2008
    #3
  4. Thanks for your reply Joe,

    If there is anything else need help later, welcome to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "Joe" <>
    >References: <>

    <>
    >Subject: Re: FormsAuthentication and GetRedirectUrl
    >Date: Thu, 14 Feb 2008 11:23:43 -0500
    >
    >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
    >
    >"Steven Cheng[MSFT]" <> wrote in message
    >news:...
    >> 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.
    >> --------------------
    >>>From: "Joe" <>
    >>>Subject: FormsAuthentication and GetRedirectUrl
    >>>Date: Tue, 12 Feb 2008 12:40:33 -0500

    >>
    >>>
    >>>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
    >>>
    >>>
    >>>

    >>

    >
    >
    >
    Steven Cheng[MSFT], Feb 15, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHk=?=

    Help!! RedirectFromLoginPage and GetRedirectUrl

    =?Utf-8?B?U2FuZHk=?=, May 26, 2005, in forum: ASP .Net
    Replies:
    9
    Views:
    2,877
    =?Utf-8?B?U2FuZHk=?=
    May 26, 2005
  2. =?Utf-8?B?c3Rzb25n?=

    1.x FormsAuthentication.GetRedirectUrl doesn't redirect

    =?Utf-8?B?c3Rzb25n?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,184
    =?Utf-8?B?c3Rzb25n?=
    Apr 10, 2006
  3. Rafi
    Replies:
    0
    Views:
    122
  4. Brian Adkins
    Replies:
    1
    Views:
    245
    Brian Adkins
    Feb 24, 2004
  5. Dominick Baier

    FormsAuthentication.GetRedirectUrl()

    Dominick Baier, Sep 10, 2006, in forum: ASP .Net Security
    Replies:
    2
    Views:
    485
    Alex Maghen
    Sep 10, 2006
Loading...

Share This Page