Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Log user in

Reply
Thread Tools

Log user in

 
 
Andrew Banks
Guest
Posts: n/a
 
      04-07-2004
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?


 
Reply With Quote
 
 
 
 
Viktor Jevdokimov
Guest
Posts: n/a
 
      04-07-2004
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" <(E-Mail Removed)> wrote in message
news:ACUcc.4827$(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
 
 
 
Andrew Banks
Guest
Posts: n/a
 
      04-07-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:ACUcc.4827$(E-Mail Removed)...
> > 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?
> >
> >

>
>



 
Reply With Quote
 
Viktor Jevdokimov
Guest
Posts: n/a
 
      04-08-2004
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" <(E-Mail Removed)> wrote in message
news:Yi%cc.5155$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:ACUcc.4827$(E-Mail Removed)...
> > > 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?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My.Log.Writeexception not writing to Application Event Log. =?Utf-8?B?VG9tIFdpbmdlcnQ=?= ASP .Net 0 01-20-2006 06:41 PM
XP: Can't log on as a regular user, I get TEMP USER? lbbss Computer Support 0 02-11-2005 05:41 PM
Log On Screen Changed. No More Auto-Log On. Jerry G. Computer Support 2 10-22-2004 09:58 AM
Urgent Pls: Facing problem in reading Log information from Log file, created by IIS Amratash ASP .Net 0 04-13-2004 09:08 AM
Need help on the Permissions needed to log to Event Log from ASP.NET? Henrik_the_boss ASP .Net 0 11-05-2003 10:14 AM



Advertisments