views:

33

answers:

2

I have a home page that is very design-specific, down to the pixel. It needs to have username/password/login, but I can't have it showing any error messages there. There is a separate standalone login page that is not design-specific and can show any messages. It's using the standard Login control.

Is there an easy way to link the two so that if an error occurs on the home page the standalone page comes up with the errors? I know I can programmatically/manually handle most of this if need be.

+1  A: 

Hey,

Try tapping into the various events it raises (LoginError or maybe LoggedIn) and redirect to your error page from that event handler when an error has occurred.

HTH.

Brian
The "error page" is normally the `Login` control's standard error message. If the home page handles the authentication, how would I force the `Login` control to use the error message from the previous page? Or, how would I *pass through* the user/pass to the other page? With regular forms I could set the action to the other page, but with the ASP.NET postback model/page lifecycle that's trickier.
Nelson
Well, in the loginerror event handler, you can response.redirect("~/error.aspx?querystringParams") there, but I would not pass the user/password through the querystring... you could use session... why do you need to pass the user/pass to the error page?
Brian
The error page is really a standalone login page. If I can pass the authentication info then the authentication logic gets isolated on that page. It's just one option on how to approach this, but not required.
Nelson
A: 

Turns out the Login control has a FailureAction property which defaults to Refresh (reload current page). You can set it to RedirectToLoginPage, which does a URL redirect with loginfailure=1. The login page then shows a generic Your login attempt was not successful. Please try again. message, instead of a specific message. Not exactly what I was looking for, but this is too easy to pass up and implement a custom solution.

Nelson
You know you can also use Response.Redirect, and pass through errors in QueryString, or (better) stick the errors in the HttpContext.Current.Items and use Server.Transfer to the login page.
RPM1984