SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast dpmoe's Avatar
    Join Date
    Apr 2005
    0 Post(s)
    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 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

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


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

    <compilation debug="true"/>
    <authentication mode="Forms" />
    <deny users="?" />


    and here is the Login.aspx

    <%@ Import Namespace="System.Data.OleDb" %>
    <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);

    objDR = objCmd.ExecuteReader();
    userFound = objDR.Read();

    return userFound;
    <form runat="server">

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

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

    <table width="100%" border="0" cellspacing="0" cellpadding="10">
    <td valign="top" width="160">
    <!-- HyperLink Controls removed from login page -->
    <td valign="top">
    <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>



    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

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


Posting Permissions

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