How to set redirect default on login?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Re: How to set redirect default on login?

    Sorry, FormsAuthentication is hard set to "default.aspx" when doing the
    RedirectFromLoginPage and/or GetRedirectUrl [which is called by
    RedirectFromLoginPage]

    Just execute SetAuthCookie and then if Request.QueryString["ReturnUrl"] is
    null, then redirect to where you want:

    if( [password check passed )
    {
    FormsAuthentication.SetAuthCookie( [username], [create persistent
    cookie] );
    string returnUrl = Request.QueryString["ReturnUrl"];
    if( returnUrl == null || returnUrl.Length < 1 )
    returnUrl = "default.aspx";
    Response.Redirect( returnUrl, true );
    }
    --
    Eric Newton
    [email]eric@ensoft-software.com[/email]
    C#/ASP.net Solutions developer

    "Lauchlan M" <LMackinnon@Hotmail.com> wrote in message
    news:e4J1zVwZDHA.2960@tk2msftngp13.phx.gbl...
    > I want to set the default value for where
    >
    > FormsAuthentication.RedirectFromLoginPage
    >
    > sends you if it doesn't have a return value already.
    >
    > eg after lgin you might wat to send them to /mysecurearea/main.aspx
    instead
    > of default.aspx.
    >
    > At the moment it always defaults to default.aspx.
    >
    > Thanks!
    >
    > Lauchlan M
    >
    >

    Eric Newton Guest

  2. Similar Questions and Discussions

    1. Login Redirect
      Hi, all I have this login script that calls on itself to authenticate the username and the password. It redisplays the login page if there is an...
    2. Cookie not set after login and redirect
      Hello I have setup a forms authentication login page and use custom principal and identity. When authenticate everything goes well. But when I set...
    3. login redirect doesn't work
      Hello, I'm working on a asp.net/C# project, but I haven't got a lot of experience with programming with C# and the dotnet framework. I've build...
    4. best way to redirect asp to login htm page?
      Hello, I need users to access a data entry asp page via a login page. If they bookmark the data entry asp I want to redirect them to the login...
    5. User Login to Redirect using PHP
      I've read many posts about redirecting a user by specifying the directin url in the database, but have had very little luck. I'm using Dreamweaver's...
  3. #2

    Default Re: How to set redirect default on login?

    This is silly design on MS's part IMO.

    If I have a page Login.aspx and use
    FormsAuthentication.RedirectFromLoginPage it _has_ to go to a default.aspx
    in the same directory, and so _cannot_ go to my secure folder. So I end up
    with a default.aspx that just redirects to where I really want it to go
    which seems like (and is) a cludge.

    And what would happen if my login page _was_ default.aspx? Would it just
    cycle around to itself on successful login?

    Sometimes the .net framework is amazing, sometimes you wonder whether MS
    really thought about any of this.

    Lauchlan M
    > Sorry, FormsAuthentication is hard set to "default.aspx" when doing the
    > RedirectFromLoginPage and/or GetRedirectUrl [which is called by
    > RedirectFromLoginPage]
    >
    > Just execute SetAuthCookie and then if Request.QueryString["ReturnUrl"] is
    > null, then redirect to where you want:
    >
    > if( [password check passed )
    > {
    > FormsAuthentication.SetAuthCookie( [username], [create persistent
    > cookie] );
    > string returnUrl = Request.QueryString["ReturnUrl"];
    > if( returnUrl == null || returnUrl.Length < 1 )
    > returnUrl = "default.aspx";
    > Response.Redirect( returnUrl, true );
    > }

    Lauchlan M Guest

  4. #3

    Default Re: How to set redirect default on login?

    I agree, there are parts of individual classes where some methods are well
    written and thought out, and other methods are just silly...

    GetRedirectUrl is one of them, it takes two parameters but doesnt even TRULY
    use them [it checks the username to see if null and just returns a null if
    so]

    In my code, if I use GetRedirectUrl You'll frequently see "string url =
    FormsAuthentication.GetRedirectUrl("SILLY_BOGUS_US ERNAME_HERE", false)


    --
    Eric Newton
    [email]eric@ensoft-software.com[/email]
    C#/ASP.net Solutions developer

    "Lauchlan M" <LMackinnon@Hotmail.com> wrote in message
    news:%239cwOa2ZDHA.1580@tk2msftngp13.phx.gbl...
    > This is silly design on MS's part IMO.
    >
    > If I have a page Login.aspx and use
    > FormsAuthentication.RedirectFromLoginPage it _has_ to go to a default.aspx
    > in the same directory, and so _cannot_ go to my secure folder. So I end
    up
    > with a default.aspx that just redirects to where I really want it to go
    > which seems like (and is) a cludge.
    >
    > And what would happen if my login page _was_ default.aspx? Would it just
    > cycle around to itself on successful login?
    >
    > Sometimes the .net framework is amazing, sometimes you wonder whether MS
    > really thought about any of this.
    >
    > Lauchlan M
    >
    > > Sorry, FormsAuthentication is hard set to "default.aspx" when doing the
    > > RedirectFromLoginPage and/or GetRedirectUrl [which is called by
    > > RedirectFromLoginPage]
    > >
    > > Just execute SetAuthCookie and then if Request.QueryString["ReturnUrl"]
    is
    > > null, then redirect to where you want:
    > >
    > > if( [password check passed )
    > > {
    > > FormsAuthentication.SetAuthCookie( [username], [create persistent
    > > cookie] );
    > > string returnUrl = Request.QueryString["ReturnUrl"];
    > > if( returnUrl == null || returnUrl.Length < 1 )
    > > returnUrl = "default.aspx";
    > > Response.Redirect( returnUrl, true );
    > > }
    >
    >

    Eric Newton Guest

  5. #4

    Default Re: How to set redirect default on login?

    Heh heh.

    You might get caught out with that when the framework changes <g>

    Lauchlan M
    > GetRedirectUrl is one of them, it takes two parameters but doesnt even
    TRULY
    > use them [it checks the username to see if null and just returns a null if
    > so]
    >
    > In my code, if I use GetRedirectUrl You'll frequently see "string url =
    > FormsAuthentication.GetRedirectUrl("SILLY_BOGUS_US ERNAME_HERE", false)

    Lauchlan M Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139