A simple Login Application using VS2005 Visual Web Express

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello,

I wanted to develop a very simple login application by using VS 2005 Visual Web Express. It doesn't work. I posted it MS ASP.Net page. It got >4000 hits and it still doesn't work. See if I can get any help from this forum that would make it work. This is what I want to do:

Currently in the user database (users and their memberships were created by ASP.config utility in VS2005) there are two users:

1. Username:admin, Password: password@123

2. UserName: user, Password: password@123


There are three aspx pages:

1. Default.apsx:

a) LoginStatus1 control

b) LoginName1 control

c) LoginView1 control

2. LogingTest.aspx:

a) Login1 control


3. Demo.aspx: DestinationPageUrl="~/Demo.aspx"


a) Two radiobutton controls

b) CreateUserWizard1 control


Required functionality:


1. If user is admin, load the page called demo and display everything on this page


2. If the user is user (or any user) than load the page demo and do not show CreateUserWizard1 control on this page

3. If any user clicks on any of the buttons open a different page with different functions

The only routine I think I need is the LoggedIn with a code like this in the TestLogin.apsx:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn

If (User.Identity.IsAuthenticated) Then
Server.Transfer("Demo.aspx")
End If

End Sub


And in the demo.aspx

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If (Session("Check") <> Nothing) And Convert.ToBoolean(Session("Check")) Then

Dim str As String = User.Identity.Name

If User.Identity.Name = "admin" And User.Identity.IsAuthenticated = True Then
CreateUserWizard1.Visible = True
Else

If optTMDemo.Checked = True Then
Server.Transfer("page1.aspx")
End If

If optPMDemo.Checked = True Then
Server.Transfer("page2.aspx")
End If

End If

End If

End Sub


In nowhere in the program I can get User.Identity.Name to have a value other than empty and the User.Identity.IsAuthenticated is always false! Where do these variables change? When I debug the code, the execution comes twice to LoginTest and always they are empty and false. If the user is admin, I get to default page back and LoginStatus reports that admin is logged in!


I can send the whole code to anybody interested. Any help will be greatly appreciated.

Thank you very much.

Athena


Default.aspx:

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

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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 runat="server">

</head>
<body>

<form id="form1" runat="server">
<div>
<span style="font-size: 10pt; font-family: Verdana">Support Options<br />
<br />
Support functions require you to login to a secure web site<br />
</span>
<span style="font-size: 10pt; font-family: Verdana">&nbsp;</span>
<br />
<table style="width: 447px">
<tr>
<td style="width: 444px">
<asp:LoginStatus
ID="LoginStatus1" runat="server" Font-Names="Verdana" Font-Size="10pt" Width="34px" />
</td>
</tr>
<tr>
<td style="width: 444px; height: 20px">
<asp:LoginName ID="LoginName1" runat="server" Font-Names="Verdana" Font-Size="10pt"
FormatString="Hello {0}" Style="z-index: 100; left: 15px; position: absolute;
top: 110px" />
</td>
</tr>
<tr>
<td style="width: 444px; height: 77px">
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<span style="font-size: 10pt; font-family: Verdana">You are now &nbsp;logged in. Welcome.</span>&nbsp;<br />
<br />
</LoggedInTemplate>
<AnonymousTemplate>
<span style="font-size: 10pt; font-family: Verdana">You are not logged in. Click the
login link to sign in.</span>
</AnonymousTemplate>
</asp:LoginView>
</td>
</tr>
</table>

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

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

Demo,aspx

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

<%@ Page Language="VB" %>

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

<script runat="server">


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If (Session("Check") <> Nothing) And Convert.ToBoolean(Session("Check")) Then

Dim str As String = User.Identity.Name

If User.Identity.Name = "admin" And User.Identity.IsAuthenticated = True Then
CreateUserWizard1.Visible = True
Else

If optTMDemo.Checked = True Then
Server.Transfer("page1.aspx")
End If

If optPMDemo.Checked = True Then
Server.Transfer("page2.aspx")
End If

End If

End If

</script>

<html xmlns="http://www.w3.org/1999/xhtml"; >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" >
<div>
<div>
<asp:RadioButton ID="optTMDemo" runat="server" Font-Names="Verdana" Font-Size="10pt"
ForeColor="#336699" Style="z-index: 100; left: 7px; position: absolute; top: 69px"
Text="Tumor Management System Demo" />
<asp:RadioButton ID="optPMDemo" runat="server" Font-Names="Verdana" Font-Size="10pt"
ForeColor="#336699" Style="z-index: 101; left: 7px; position: absolute; top: 51px"
Text="Paw Management System Demo" />
<asp:Label ID="Label1" runat="server" Font-Names="Verdana" Font-Size="10pt" ForeColor="#336699"
Style="z-index: 102; left: 10px; position: absolute; top: 21px" Text="Product demos"></asp:Label>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em"
Style="z-index: 104; left: 11px; position: absolute; top: 125px">
<SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top" />
<SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
<ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
ForeColor="White" HorizontalAlign="Center" />
<CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<StepStyle BorderWidth="0px" />
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</div>

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


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

web.config

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

<?xml version="1.0"?>

<configuration>
<appSettings/>
<connectionStrings/>
<system.web>

<authentication mode="Forms">
loginUrl="~/LoginTest.aspx"
slidingExpiration="true"
cookieless="UseCookies"
protection="All"
timeout="30" path="/" />
</authentication>


<membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers></membership>
<roleManager enabled="true" />
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>

<compilation debug="true"/></system.web>
<system.net>
<mailSettings>
<smtp from="hiittite@gmail,com">
<network host="localhost" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>
</configuration>


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

LoginTest.aspx

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

<%@ Page Language="VB" %>

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

<script runat="server">


Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn

If (User.Identity.IsAuthenticated) Then
Server.Transfer("Demo.aspx")
End If

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml"; >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#333333" OnLoggedIn="Login1_LoggedIn" DestinationPageUrl="~/Demo.aspx">
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
</asp:Login>

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

.



Relevant Pages

  • Re: nntp server, iis6, 2003 server
    ... > In IIS Manager, NNTP Virtual Server properties, Access tab, Authentication ... > requires you to login and supply the admin account name and password. ... > you have access to the "control" folder and NNTP will accept control ...
    (microsoft.public.inetserver.iis.smtp_nntp)
  • Absolute path of insdie file shouldnt come without admin or user login first, how?
    ... I have login page with javascript, checks login-id and password, admin/ ... admin and user/user, once admin or user login, it brings control page ...
    (comp.lang.javascript)
  • Re: Role authorization, if denied access, how NOT to kick back to login?
    ... If you're using the built-in menu control, it has an option to do security group menu purging, meaning that only admin users would see the admin menu items. ... If a non-admin is guessing at trying to find admin page urls, rather than picking from a menu, bumping back to the login page would seem appropriate. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Role authorization, if denied access, how NOT to kick back to login?
    ... built-in menu control, it has an option  to do security group menu purging, ... meaning that only admin users would see the admin menu items. ... urls, rather than picking from a menu, bumping back to the login page would ... I am already doing what you said, i.e., only admin users will see the ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Macro to VBA
    ... Database Administrator ... Dim Ret as Long 'Return Value ... Static iLogAttempts as Integer 'Number of Login Attempts ... 'Save the logged user to somwhere, in this case to a control on form Home ...
    (microsoft.public.access.modulesdaovba)