I would like to create the page on which I would have to type login and password to go to another page

Last post 03-05-2007 5:07 AM by Zhao Ji Ma - MSFT. 2 replies.

Sort Posts:

  • Confused [*-)] I would like to create the page on which I would have to type login and password to go to another page

    03-03-2007, 7:51 PM
    • Loading...
    • szmitek
    • Joined on 03-04-2007, 12:22 AM
    • Chotomów, Poland
    • Posts 59

    I would like to create the page on which I would have to type login (szmitek) and password (password) to go to another page (admin.aspx). I have created this page but I cannot login. Why? I use MS Visual Web Developer 2005 XE and MS Expression Web.

    <%

    @ Page Language="c#"%>

    <

    SCRIPT runat="server">

    private

    bool SiteSpecificAuthenticationMethod(string UserName, string Password)

    {

    return false;

    }

    private

    void OnAuthenticate(object sender, AuthenticateEventArgs e)

    {

    bool Authenticated = false;

    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

    string UserName = "szmitek";

    string Password = "password";

    e.Authenticated = Authenticated;

    }

    </

    SCRIPT>

    <!

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <

    html xmlns="http://www.w3.org/1999/xhtml">

    <

    head>

    <

    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />

    <

    title>Administracja - logowanie</title>

    <

    link rel="stylesheet" type="text/css" href="../format.css"/>

    </

    head>

    <

    body>

    <

    h1>Zaloguj się</h1>

    <div class="center">

    <form runat="server" onsubmit="AuthenticateEventArgs">

    <asp:Login runat="server" id="Login1" BorderColor="#E6E2D8" BorderPadding="4" BackColor="#F7F6F3" BorderWidth="1px" ForeColor="#333333" BorderStyle="Solid" Font-Size="0.8em" Font-Names="Verdana" LoginButtonText="Zaloguj się" PasswordLabelText="Hasło:" RememberMeText="Loguj automatycznie" TitleText="Logowanie" UserNameLabelText="Login:" DestinationPageUrl="admin.aspx" PasswordRequiredErrorMessage="Błędne hasło" UserNameRequiredErrorMessage="Błędny login" OnAuthenticate="OnAuthenticate">

    <TitleTextStyle BackColor="#5D7B9D" ForeColor="White" Font-Size="0.9em" Font-Bold="True" />

    <InstructionTextStyle ForeColor="Black" Font-Italic="True" />

    <TextBoxStyle Font-Size="0.8em" />

    <LoginButtonStyle BackColor="#FFFBFF" BorderStyle="Solid" ForeColor="#284775" BorderWidth="1px" BorderColor="#CCCCCC" Font-Size="0.8em" Font-Names="Verdana" />

    </asp:Login></form>

    </div>

    </

    body>

    </

    html>
  • Re: I would like to create the page on which I would have to type login and password to go to another page

    03-04-2007, 7:56 AM

    you can solve ur problem by removing the onauthenticate and using the event onLoggedIn,

    protected void Login1_OnLoggedIn(object sender, EventArgs e)

    {

          Response.Redirect("admin.aspx");

    }

    This will solve ur problem

    Regards
    Ramzi
    --------------------------------------------
    Dont Forget to mark the post as answered once replied.
  • Re: I would like to create the page on which I would have to type login and password to go to another page

    03-05-2007, 5:07 AM
    Answer

    Hi,

    OnAuthenticate is used to implement a custom authentication scheme.

    Do you want to simply hardcode username and password in your web application?

    string UserName = "szmitek";

     

    string Password = "password";

     

    If so, you can try following:

    private

    void OnAuthenticate(object sender, AuthenticateEventArgs e)

    {

     

    bool Authenticated = false;

     

    string UserName = "szmitek";

     

    string Password = "password";

    if((Login1.UserName == UserName) && (Login1.Password == Password))

     Authenticated = true; 

    e.Authenticated = Authenticated;

    }

     

    And on user login:

    protected void Login1_OnLoggedIn(object sender, EventArgs e)

    {

          Response.Redirect("admin.aspx");

    }

     

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter