A simple Login Application using VS2005 Visual Web Express

A

Athena

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top