473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Hello everyone...

Hi there everyone, I'm new to this newsgroup so I hope you don't mind me just asking a question, but it has been working me for way to long now and I need some help. I'm fairly new to ASP.NET and VB.NET but have been cramming for weeks now and hit a snag.It has to do with forms authentication in ASP.NET. My problem is that when good credentials are sent from the login.aspx page it doesn't seem to be generating a cookie for the user and sends the user back to the login page because they are still unauthenticated. I have been researching this allot and have been buried in books for way to long now. Creating the login system seems so easy to do that there are little troubleshooting pages to be found. I did find one that described my problem in one short paragraph:

[http://msdn.microsoft.com/library/de...ecNetch13.asp]
Using Forms Authentication
Make sure that the cookie name specified in the <forms> element is being retrieved in the global.asax event handler correctly (Application_AuthenticateRequest). Also, make sure the cookie is being created. If the client is continuously sent back to the login page (specified by the loginUrl attribute on the <forms> element) this indicates that the cookie is not being created for some reason, or an authenticated identity is not being placed into the context (HttpContext.User)
The structure I have is fairly simple. I have the root of my main application open to anonymous users. I then have a secured directory called 'ClientCenter'. Both have there own web.config files specifying there separate authorization.

At the root of my site I have my the main sites web.config file which looks like so:

[code]
<configuration>
<appSettings>
<add key="MM_CONNECTION_HANDLER_eOnConn" value="default_oledb.htm" />
<add key="MM_CONNECTION_STRING_eOnConn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\eOn\Database\eOn.mdb;Per sist Security Info=False" />
<add key="MM_CONNECTION_DATABASETYPE_eOnConn" value="OleDb" />
<add key="MM_CONNECTION_SCHEMA_eOnConn" value="" />
<add key="MM_CONNECTION_CATALOG_eOnConn" value="" />
</appSettings>

<system.web>
<authentication mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx" protection="All">
<credentials passwordFormat="Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</configuration>

My login page code (with some help from the MSDN) looks like so:

[code]
<%@ Page Language="VB" AutoEventWireup="true" %>
<html>
<head>
<script runat="server">
Sub LoginBtn_Click(sender as Object, e as EventArgs)
' If Page.IsValid Then
' Call the authentication event handler delegate (not included in this example).
If FormsAuthentication.Authenticate(UserName.Text, UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentication.RedirectFromLoginPage(UserName .Text, Remember.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
' End If
End Sub
</script>

</head>

<body>
<form runat="server">
<h2>Login Page</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>Username:</td>
<td><asp:TextBox id="UserName" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
Display="Static" ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="UserPass" runat="server" TextMode="Password"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="UserPass"
Display="Static" ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember" runat="server"></asp:CheckBox>Remember credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server" text="Login"></asp:button>
<p><asp:Label id="Msg" runat="server" ForeColor="red"></asp:Label></p>
</form>
</body>
</html>

And lastly the ClientCenter/web.config file looks like this:

[code]
<configuration>
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</configuration>

Now from all the books and examples I have been through, this should be all I need to get this login system up and running, right? Well something is going on here and i have no clue what. Please could someone show me what I am doing wrong here and why it is not generating my cookie! How do i ' Call the authentication event handler delegate' and what is that exactly? Do i have to set something in IIS for this to work? Please help!

Thanks
Nugs

Nov 18 '05 #1
3 1511
Let's start by elminating the simple: Are you sure that the browser has
Cookies enabled?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Nugs" <du*******@comcast.net> wrote in message
news:ma********************@comcast.com...
Hi there everyone, I'm new to this newsgroup so I hope you don't mind me
just asking a question, but it has been working me for way to long now and I
need some help. I'm fairly new to ASP.NET and VB.NET but have been cramming
for weeks now and hit a snag.It has to do with forms authentication in
ASP.NET. My problem is that when good credentials are sent from the
login.aspx page it doesn't seem to be generating a cookie for the user and
sends the user back to the login page because they are still
unauthenticated. I have been researching this allot and have been buried in
books for way to long now. Creating the login system seems so easy to do
that there are little troubleshooting pages to be found. I did find one that
described my problem in one short paragraph:
[http://msdn.microsoft.com/library/de...-us/dnnetsec/h
tml/SecNetch13.asp]
Using Forms Authentication
Make sure that the cookie name specified in the <forms> element is being
retrieved in the global.asax event handler correctly
(Application_AuthenticateRequest). Also, make sure the cookie is being
created. If the client is continuously sent back to the login page
(specified by the loginUrl attribute on the <forms> element) this indicates
that the cookie is not being created for some reason, or an authenticated
identity is not being placed into the context (HttpContext.User)
The structure I have is fairly simple. I have the root of my main
application open to anonymous users. I then have a secured directory called
'ClientCenter'. Both have there own web.config files specifying there
separate authorization.

At the root of my site I have my the main sites web.config file which looks
like so:

[code]
<configuration>
<appSettings>
<add key="MM_CONNECTION_HANDLER_eOnConn" value="default_oledb.htm"
/>
<add key="MM_CONNECTION_STRING_eOnConn"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\eOn\Database\eOn.mdb;Per sist Security Info=False"
/>
<add key="MM_CONNECTION_DATABASETYPE_eOnConn" value="OleDb" />
<add key="MM_CONNECTION_SCHEMA_eOnConn" value="" />
<add key="MM_CONNECTION_CATALOG_eOnConn" value="" />
</appSettings>

<system.web>
<authentication mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All">
<credentials passwordFormat="Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</configuration>

My login page code (with some help from the MSDN) looks like so:

[code]
<%@ Page Language="VB" AutoEventWireup="true" %>
<html>
<head>
<script runat="server">
Sub LoginBtn_Click(sender as Object, e as EventArgs)
' If Page.IsValid Then
' Call the authentication event handler delegate (not
included in this example).
If FormsAuthentication.Authenticate(UserName.Text,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentication.RedirectFromLoginPage(UserName .Text,
Remember.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
' End If
End Sub
</script>

</head>

<body>
<form runat="server">
<h2>Login Page</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>Username:</td>
<td><asp:TextBox id="UserName"
runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator1"
runat="server" ControlToValidate="UserName"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="UserPass" runat="server"
TextMode="Password"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator2"
runat="server" ControlToValidate="UserPass"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"></asp:CheckBox>Remember credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login"></asp:button>
<p><asp:Label id="Msg" runat="server"
ForeColor="red"></asp:Label></p>
</form>
</body>
</html>

And lastly the ClientCenter/web.config file looks like this:

[code]
<configuration>
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</configuration>

Now from all the books and examples I have been through, this should be all
I need to get this login system up and running, right? Well something is
going on here and i have no clue what. Please could someone show me what I
am doing wrong here and why it is not generating my cookie! How do i ' Call
the authentication event handler delegate' and what is that exactly? Do i
have to set something in IIS for this to work? Please help!

Thanks
Nugs
Nov 18 '05 #2
Yes, the same login example works when run from other servers. When I run it
locally nothing happens.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Let's start by elminating the simple: Are you sure that the browser has
Cookies enabled?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Nugs" <du*******@comcast.net> wrote in message
news:ma********************@comcast.com...
Hi there everyone, I'm new to this newsgroup so I hope you don't mind me
just asking a question, but it has been working me for way to long now and I need some help. I'm fairly new to ASP.NET and VB.NET but have been cramming for weeks now and hit a snag.It has to do with forms authentication in
ASP.NET. My problem is that when good credentials are sent from the
login.aspx page it doesn't seem to be generating a cookie for the user and
sends the user back to the login page because they are still
unauthenticated. I have been researching this allot and have been buried in books for way to long now. Creating the login system seems so easy to do
that there are little troubleshooting pages to be found. I did find one that described my problem in one short paragraph:
[http://msdn.microsoft.com/library/de...-us/dnnetsec/h tml/SecNetch13.asp]
Using Forms Authentication
Make sure that the cookie name specified in the <forms> element is being
retrieved in the global.asax event handler correctly
(Application_AuthenticateRequest). Also, make sure the cookie is being
created. If the client is continuously sent back to the login page
(specified by the loginUrl attribute on the <forms> element) this indicates that the cookie is not being created for some reason, or an authenticated
identity is not being placed into the context (HttpContext.User)
The structure I have is fairly simple. I have the root of my main
application open to anonymous users. I then have a secured directory called 'ClientCenter'. Both have there own web.config files specifying there
separate authorization.

At the root of my site I have my the main sites web.config file which looks like so:

[code]
<configuration>
<appSettings>
<add key="MM_CONNECTION_HANDLER_eOnConn" value="default_oledb.htm" />
<add key="MM_CONNECTION_STRING_eOnConn"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\eOn\Database\eOn.mdb;Per sist Security Info=False" />
<add key="MM_CONNECTION_DATABASETYPE_eOnConn" value="OleDb" />
<add key="MM_CONNECTION_SCHEMA_eOnConn" value="" />
<add key="MM_CONNECTION_CATALOG_eOnConn" value="" />
</appSettings>

<system.web>
<authentication mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All">
<credentials passwordFormat="Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</configuration>

My login page code (with some help from the MSDN) looks like so:

[code]
<%@ Page Language="VB" AutoEventWireup="true" %>
<html>
<head>
<script runat="server">
Sub LoginBtn_Click(sender as Object, e as EventArgs)
' If Page.IsValid Then
' Call the authentication event handler delegate (not
included in this example).
If FormsAuthentication.Authenticate(UserName.Text,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentication.RedirectFromLoginPage(UserName .Text,
Remember.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
' End If
End Sub
</script>

</head>

<body>
<form runat="server">
<h2>Login Page</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>Username:</td>
<td><asp:TextBox id="UserName"
runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="UserPass" runat="server"
TextMode="Password"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="UserPass"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"></asp:CheckBox>Remember credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login"></asp:button>
<p><asp:Label id="Msg" runat="server"
ForeColor="red"></asp:Label></p>
</form>
</body>
</html>

And lastly the ClientCenter/web.config file looks like this:

[code]
<configuration>
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</configuration>

Now from all the books and examples I have been through, this should be all I need to get this login system up and running, right? Well something is
going on here and i have no clue what. Please could someone show me what I
am doing wrong here and why it is not generating my cookie! How do i ' Call the authentication event handler delegate' and what is that exactly? Do i
have to set something in IIS for this to work? Please help!

Thanks
Nugs

Nov 18 '05 #3
Well the Microsoft page I mentioned previously says: "Make sure that the
cookie name specified in the <forms> element is being retrieved in the
global.asax event handler correctly (Application_AuthenticateRequest)"

I don't believe I have done anything like this and in all the example I have
read on this none have mentioned a global.asax event handler. Is this maybe
my problem?

Nugs

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Let's start by elminating the simple: Are you sure that the browser has
Cookies enabled?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Nugs" <du*******@comcast.net> wrote in message
news:ma********************@comcast.com...
Hi there everyone, I'm new to this newsgroup so I hope you don't mind me
just asking a question, but it has been working me for way to long now and I need some help. I'm fairly new to ASP.NET and VB.NET but have been cramming for weeks now and hit a snag.It has to do with forms authentication in
ASP.NET. My problem is that when good credentials are sent from the
login.aspx page it doesn't seem to be generating a cookie for the user and
sends the user back to the login page because they are still
unauthenticated. I have been researching this allot and have been buried in books for way to long now. Creating the login system seems so easy to do
that there are little troubleshooting pages to be found. I did find one that described my problem in one short paragraph:
[http://msdn.microsoft.com/library/de...-us/dnnetsec/h tml/SecNetch13.asp]
Using Forms Authentication
Make sure that the cookie name specified in the <forms> element is being
retrieved in the global.asax event handler correctly
(Application_AuthenticateRequest). Also, make sure the cookie is being
created. If the client is continuously sent back to the login page
(specified by the loginUrl attribute on the <forms> element) this indicates that the cookie is not being created for some reason, or an authenticated
identity is not being placed into the context (HttpContext.User)
The structure I have is fairly simple. I have the root of my main
application open to anonymous users. I then have a secured directory called 'ClientCenter'. Both have there own web.config files specifying there
separate authorization.

At the root of my site I have my the main sites web.config file which looks like so:

[code]
<configuration>
<appSettings>
<add key="MM_CONNECTION_HANDLER_eOnConn" value="default_oledb.htm" />
<add key="MM_CONNECTION_STRING_eOnConn"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\eOn\Database\eOn.mdb;Per sist Security Info=False" />
<add key="MM_CONNECTION_DATABASETYPE_eOnConn" value="OleDb" />
<add key="MM_CONNECTION_SCHEMA_eOnConn" value="" />
<add key="MM_CONNECTION_CATALOG_eOnConn" value="" />
</appSettings>

<system.web>
<authentication mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All">
<credentials passwordFormat="Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</configuration>

My login page code (with some help from the MSDN) looks like so:

[code]
<%@ Page Language="VB" AutoEventWireup="true" %>
<html>
<head>
<script runat="server">
Sub LoginBtn_Click(sender as Object, e as EventArgs)
' If Page.IsValid Then
' Call the authentication event handler delegate (not
included in this example).
If FormsAuthentication.Authenticate(UserName.Text,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentication.RedirectFromLoginPage(UserName .Text,
Remember.Checked)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
' End If
End Sub
</script>

</head>

<body>
<form runat="server">
<h2>Login Page</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>Username:</td>
<td><asp:TextBox id="UserName"
runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="UserPass" runat="server"
TextMode="Password"></asp:TextBox></td>
<td><asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="UserPass"
Display="Static"
ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"></asp:CheckBox>Remember credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login"></asp:button>
<p><asp:Label id="Msg" runat="server"
ForeColor="red"></asp:Label></p>
</form>
</body>
</html>

And lastly the ClientCenter/web.config file looks like this:

[code]
<configuration>
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</configuration>

Now from all the books and examples I have been through, this should be all I need to get this login system up and running, right? Well something is
going on here and i have no clue what. Please could someone show me what I
am doing wrong here and why it is not generating my cookie! How do i ' Call the authentication event handler delegate' and what is that exactly? Do i
have to set something in IIS for this to work? Please help!

Thanks
Nugs

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Spidey | last post by:
for(;0;) printf("hello"); even the condition s wrong i get a hello printed on the screen y s this happening
1
by: flyreally | last post by:
hello,everyone.I'm a Chinese student,I like C very much.I hope I can learn something here,help me if possible.Thanks!!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.