Forum Moderators: open

Message Too Old, No Replies

FormsAuthentication Redirect

no choices?

         

txbakers

8:45 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My webconfig is set to deny "?" so I can validate users.

The routine works, but I want to have a fixed target after validation, not "the page it was attempting to access".

I want a button to the login page, then have the login page either redirect to a "sorry" or a "welcome" page. It always seems to want to go somewhere else.

In classic ASP I just checked for a Session variable at the top of every page and redirected to login if it wasn't there. But that defeats the purpose of using the webconfig authentication, right?

Kind of leads me back to the post below about "why bother with .NET?"

TheNige

11:18 pm on May 13, 2005 (gmt 0)

10+ Year Member



Check out step 18 at [gotdotnet.com...]

If you are using the RedirectFromLoginPage method it automatically creates the authentication cookie. What you can do is create the cookie yourself and then redirect to any page that you want to.

also if you notice the "ReturnURL" querystring parameter on your login page....if you can find a way to override that then you can make the default RedirectFromLoginPage go anywhere you want.

Also, you could also make your login page the welcome and sorry all in one if you wanted by by displaying/hiding certain panels based on the success of the users login attempt.

it is kind of like having a navigation computer in your car...if you don't know how to use it then you'll always think it is easier to just read a map while you are driving.

txbakers

1:05 am on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks - that looks like a good tutorial.

txbakers

2:58 am on May 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The tutorial pretty much follows what is in the Murach book, but I would still need to go to another page before being redirected to the login page. When I start with the login page directly, it tried to redirect to "/" which throws errors.

Where can I specify what the redirect URL is?

So I wrote this instead:
If DB.LoginMethod(uname.Text, pwd.Text) Then
Response.Redirect("home.aspx")
Else
' Invalid credentials supplied, display message
lblNG.Text = "Incorrect username or password, please try again or contact our office."

End If

but it still picks up the ReturnUrl Parameter in there and doesn't redirect.

http://localhost/test3/login.aspx?ReturnUrl=%2ftest3%2fhome.aspx

I don't see a way to override the exisiting FormsAuthentication methods

txbakers

2:34 am on May 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This one is solved now:

all I needed to do was use :
FormsAuthentication.SetAuthCookie(uname.Text, False)
Response.Redirect(mypage.aspx)

instead of

FormsAuthentication.RedirectFromLoginPage(uname.Text, False)

one down, three million to go.