code to login manually

Discussion in 'ASP .Net' started by Cirene, Jun 4, 2008.

  1. Cirene

    Cirene Guest

    how can i log in programatically?

    i want my users to be able to specify username & password in a session var
    as an option
     
    Cirene, Jun 4, 2008
    #1
    1. Advertising

  2. Cirene

    Cirene Guest

    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?

    "Cirene" <> wrote in message
    news:...
    > how can i log in programatically?
    >
    > i want my users to be able to specify username & password in a session var
    > as an option
    >
     
    Cirene, Jun 4, 2008
    #2
    1. Advertising

  3. Cirene

    Cirene Guest

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

    That's the solution! Thanks.

    "Cirene" <> wrote in message
    news:uDI$...
    >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?
    >
    > "Cirene" <> wrote in message
    > news:...
    >> how can i log in programatically?
    >>
    >> i want my users to be able to specify username & password in a session
    >> var as an option
    >>

    >
    >
     
    Cirene, Jun 4, 2008
    #3
  4. 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>
     
    Michael Nemtsev [MVP], Jun 4, 2008
    #4
  5. Cirene

    Cirene Guest

    Thanks Michael!

    "Michael Nemtsev [MVP]" <> wrote in message
    news:...
    > 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>
    >
     
    Cirene, Jun 5, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    649
  2. Adam Preble

    Manually specifying the shell

    Adam Preble, Mar 17, 2005, in forum: Perl
    Replies:
    0
    Views:
    556
    Adam Preble
    Mar 17, 2005
  3. Marty
    Replies:
    2
    Views:
    5,172
    microsoft.public.dotnet.languages.csharp
    Feb 19, 2004
  4. Davy
    Replies:
    4
    Views:
    264
  5. Chris Conrad

    Must manually attach to ASPNET_WP process to debug ASP.NET code

    Chris Conrad, Mar 16, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    195
    Chris Conrad
    Mar 16, 2005
Loading...

Share This Page