I’ve got an asp:LoginStatus control, which is supposed to change to ‘Log out’ when a user logs in.
However, I have not managed to create the login process. I’ve coded the login process myself using a Session (i.e. a database is checked to validate user-provided username and password, and if valid, my code sets a Session to true, and redirects to the page which he/she may now access).
There should be no problem with the above part, as it works well. The problem is with this LoginStatus control. I have read that the control checks for isAuthenticated, but I don’t know how to set this property. Can the LoginStatus only be used with cookies, and is it not working due to my Session method of authentication?
I’ve set the login page and authentication type to “Forms” in the Web.config.
Any suggestions?
You have to mimic what the login control does; it uses
FormsAuthentication.SetAuthCookieto establish the user security cookie, then redirects from the login page. That’s what you have to use for testing. You have to do a redirect because during the lifecycle when you set the cookie, the framework doesn’t think your logged in, until after the redirect.