Custom redirectURL

W

Water Cooler v2

In Forms based authentication mode, say my login page has to be
redirected to "db.aspx" if the login was successful, how do I supply
this redirect without a Response.Redirect() using FormsAuthentication
class?

If I simply say,

If MyDatabaseUserAuthenticationMethod(txtUserName.Text,
txtPassword.Text) Then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
Else
lblMessage.Text = "Please jump into the well and die."
End If

and if the user logs in correctly, then he will, by default, be
redirected automatically to the "default.aspx" page if it exists. If
the page does not exist, he will come back to the login page because no
where in the login page have we specified an equivalant of the
primitive "action" attribute that tells whom to POST the page to, so
the same page will recieve a POSTBACK.

How do I tell ASP.NET that if the forms based authentication is
successful, take this guy to this page, say, "db.aspx"?
 
J

Juan T. Llibre

re:
How do I tell ASP.NET that if the forms based authentication
is successful, take this guy to this page, say, "db.aspx"?

You can't.

What you could do is :

1. set the default page for the application to "db.aspx"

or

2. In "default.aspx", if that's your default page, or in whatever page
you have set the default page to, set a Response.Redirect("db.aspx")
 
W

Water Cooler v2

2. In "default.aspx", if that's your default page, or in whatever page
you have set the default page to, set a Response.Redirect("db.aspx")

Hmm! this sounds do-able.

What about the first option. I didn't get it. How do you change your
default page to some other name?
 
J

Juan T. Llibre

Open the IIS Manager; scroll down the left to your application
( opening "Web Sites" and "Default Web Site"); select your App
by clicking it; then right-click your Application and select "Properties";
then click the "Documents" tab, and enter the name of the default
document you want your application to have.

Make sure you have the default documents in
the order you want ASP.NET to process them.

The default documents will be processed in the order they're listed.
 
C

Curt

You can redirect to any page you want to. Instead of
FormsAuthentication.RedirectFromLoginPage, use
FormsAuthentication.SetAuthCookie to authenitcate the user, then use
response.redirect to move to whatever page your logic chooses. I use this
for sites because different users have different start pages, but I use the
same link and login page for both.

Good luck!
Curt
 
W

Water Cooler v2

Thanks, Curt. From all the place, all I got was work-arounds to this
question: change your default in IIS console, do a response.redirect in
default.aspx to db.aspx.

I think this answer is the most sensible one because I guess that is
what RedirectFromLoginPage does:

(1) Set authentication cookie
(2) Go to default.aspx

Thanks!
 
J

Juan T. Llibre

Oh, OK...

You're absolutely right.

However, he did specify that he wanted
to do it *without* a Response.Redirect.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top