code to login manually

C

Cirene

how can i log in programatically?

i want my users to be able to specify username & password in a session var
as an option
 
C

Cirene

I tried this:
If Membership.ValidateUser(Request.QueryString("Username"),
Request.QueryString("Password")) Then
Response.Redirect("members/ViewAccount.aspx")

But, even though the login is correct, pages which I should be able to view
(because I'm a logged in user) I can't see. I'm auto-redirect to the login
page.

Any ideas?
 
C

Cirene

FormsAuthentication.SetAuthCookie(Request.QueryString("Username"), True)

That's the solution! Thanks.
 
M

Michael Nemtsev [MVP]

Hello Cirene,

You forgot to call FormsAuthentication.SetAuthCookie

Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
FormsAuthentication.SetAuthCookie("username", false);
Response.Redirect("samepage.aspx");

Also, you can use the AJAX login, see sample there http://weblogs.asp.net/andrewfrederick/archive/2008/02/18/a-client-side-ajax-login-for-asp-net.aspx

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


C> how can i log in programatically?
C>
C> i want my users to be able to specify username & password in a
C> session var as an option
C>
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top