OK, I have a login form with the login button. In the LoginButton_Click
event handler method I validate user name and password in the DB. If
validation is successfult, I have this line of code for example:
System.Web.Security.FormsAuthentication.SetAuthCoo kie(strUserName, False,
"/")
"/" is the cookie path.
Below this line I have the code I need, and finally, a redirect, since my
controls and pagest looking for a Page.User.Identity, which will be changed
ONLY with the next request, since current request was without authentication
cookie you just set with "SetAuthCookie". What else?
What I'm saying, you have to know, how your application performs a request
step by step, and is it possible to use a request context to put an
authentication info (user name, etc) on the context, and check it somewhere
in your application, instead of Page.User.Identity...
Finally, how can you determine, that "SetAuthCookie" is not working?
"Andrew Banks" <ba****@nojunkblueyonder.co.uk> wrote in message
news:Yi*********************@news-text.cableinet.net...
Sorry Viktor, I don't fully understand what you are saying.
Can anyone give an example of how I can log a user in without using
RedirectFromLoginPage?
Thanks
"Viktor Jevdokimov" <vj*********@hotmail.com> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl... SetAuthCookie will set an Auth cookie for the next request, i.e. cookie
will be sent with the response. This way you can't use User.Identity to get
an information about just logged in user without receiving a new request
with the new Auth cookie just set - you need to use your own mechanism.
"Andrew Banks" <ba****@nojunkblueyonder.co.uk> wrote in message
news:AC*********************@news-text.cableinet.net... Using forms authentication in C# I usually use
FormsAuthentication.RedirectFromLoginPage to log a user in as follows
FormsAuthentication.RedirectFromLoginPage(id,false );
How can I log a user in without re-directing them somewhere else? I
simply want to log the in and then run some other code without re-directing them.
I've tried .SetAuthCookie(id,false) but this doesn't seem to work.
Any ideas?