Altering RedirectFromLoginPage redirction page

B

Ben Fidge

Hi

I have an app that requires the following scenarios:

- A registererd user can login via a login page. This will redirect them
to Default.aspx via the use of FromsAuthentication.RedirectFromLoginPage
- A new user can register and on completion, will automatically get
logged in and then get redirected to a different page.

I can't implement the second scenario using RedirectFromLoginPage as it
insists on going to default.aspx. However, on completion of registration, it
would be very nice to autatically log the user in and then redirect them to
this other page.

Is there any way of doing this with ASP.NET?

Ben
 
M

Mr Newbie

Why dont you add the functionality to the same page ie (Login or Register),
you could optionally have a new form pop up to take the details and return
them to the login form. One successfull registration is complete, the fields
for username and password could be automatically filled in ready for login.
 
B

Ben Fidge

I actually solved it using the following in the Confirm button OnClick:

FormsAuthenticationTicket oTicket = new FormsAuthenticationTicket(
1,
sUserName
DateTime.Now,
DateTime.Now.AddMinutes(20),
false,
"",
FormsAuthentication.FormsCookiePath);

// Encrypt the ticket.
string oEncTicket = FormsAuthentication.Encrypt(oTicket);

// Create the cookie.
Response.Cookies.Add(new
HttpCookie(FormsAuthentication.FormsCookieName, oEncTicket));

Response.Redirect("UserRegistered.aspx");
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top