SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast dpmoe's Avatar
    Join Date
    Apr 2005
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How Can I Control My Loginuser to limit it to some pages on my web application...?

    Hello there

    i have got Zak book for buliding your own website using asp.net c#,

    the problem I have is as follow

    I have a site that sells videos, to be able to buy a video you need to be a member.. But you are free to browse the whole site without buying.. when a visitor try to buy a video they are redirected to a page where they should register. After that the visitor becomes a memeber and obatin a loguser name and a password. He logs and enter his password on a page called Login.aspx

    Now My problem is: As soon as you enter my site it redirects you to the Login.aspx!!! How can i stop that and makes the Login page only appear when a customer wants to sign in?


    here is the code..


    thats the web file

    <configuration>
    <appSettings>
    <add key="DSN" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Inetpub\wwwroot\Net\Database\VideoSanta1.mdb"/>
    </appSettings>

    <system.web>


    <customErrors mode="RemoteOnly" defaultRedirect="genericError.aspx">
    <error statusCode="404" redirect="pagenotfound.aspx"/>
    <error statusCode="500" redirect="applicationerror.aspx"/>
    </customErrors>

    <compilation debug="true"/>
    <authentication mode="Forms" />
    <authorization>
    <deny users="?" />
    </authorization>
    </system.web>
    </configuration>

    -----------------------------------------------------------

    and here is the Login.aspx


    <%@ Import Namespace="System.Data.OleDb" %>
    <html>
    <head>
    <title>Video Santa</title>
    <link href="styles.css" rel="stylesheet" />
    <script runat="server" language="C#">







    void LoginUser(Object s, EventArgs e) {
    bool blnAuthenticate = Authenticate(username.Text, password.Text);
    if (blnAuthenticate) {
    FormsAuthentication.RedirectFromLoginPage(username.Text, false);
    } else {
    lblError.Text = "Your login was invalid. Please try again.";
    }
    }

    bool Authenticate(string strUsername, string strPassword) {
    OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DSN"]);
    OleDbCommand objCmd;
    OleDbDataReader objDR;
    bool userFound;


    objCmd = new OleDbCommand("SELECT * FROM EmployeeTable WHERE EUserName='" + strUsername + "' AND EPassword='" + strPassword + "'", objConn);

    objConn.Open();
    objDR = objCmd.ExecuteReader();
    userFound = objDR.Read();
    objDR.Close();
    objConn.Close();

    return userFound;
    }
    </script>
    </head>
    <body>
    <form runat="server">

    <table width="100%" border="0" cellspacing="0" cellpadding="0" background="Images/header_bg.gif">
    <tr>
    <td><img src="Images/header_top.gif" width="450" height="142" alt="dorknozzle.com: the official dorknozzle company intranet" /></td>
    </tr>
    </table>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="157"><img src="Images/header_bottom.gif" width="157" height="37" alt="" /></td>
    <td></td>
    </tr>
    </table>

    <table width="100%" border="0" cellspacing="0" cellpadding="10">
    <tr>
    <td valign="top" width="160">
    <!-- HyperLink Controls removed from login page -->
    </td>
    <td valign="top">
    <h1>Login</h1>
    <p>Username: <br /><asp:TextBox id="username" runat="server" /></p>
    <p>Password: <br /><asp:TextBox id="password" runat="server" TextMode="Password" /></p>
    <p><asp:Button id="btnSubmit" runat="server" Text="Login" OnClick="LoginUser" /></p>
    <p><asp:Label id="lblError" ForeColor="Red" runat="Server" /></p>
    </td>
    </tr>
    </table>

    </form>
    </body>
    </html>

    -----------------------------

    I want this page to appear "redirected" after the user brows "shop.aspx or signIn.aspx" not by simply opening and viewing any of the products or going to the home page..


    Thanks for the help

    Regards
    Moe
    Last edited by dpmoe; Apr 11, 2005 at 07:21.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •