473,748 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Au thenticateReque st). 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.Us er)
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]
<configuratio n>
<appSettings>
<add key="MM_CONNECT ION_HANDLER_eOn Conn" value="default_ oledb.htm" />
<add key="MM_CONNECT ION_STRING_eOnC onn" value="Provider =Microsoft.Jet. OLEDB.4.0;Data Source=C:\Inetp ub\wwwroot\eOn\ Database\eOn.md b;Persist Security Info=False" />
<add key="MM_CONNECT ION_DATABASETYP E_eOnConn" value="OleDb" />
<add key="MM_CONNECT ION_SCHEMA_eOnC onn" value="" />
<add key="MM_CONNECT ION_CATALOG_eOn Conn" value="" />
</appSettings>

<system.web>
<authenticati on mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx" protection="All ">
<credentials passwordFormat= "Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorizatio n>
<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 FormsAuthentica tion.Authentica te(UserName.Tex t, UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentica tion.RedirectFr omLoginPage(Use rName.Text, Remember.Checke d)
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:TextBo x id="UserName" runat="server"> </asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator1" runat="server" ControlToValida te="UserName"
Display="Static " ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td>Password: </td>
<td><asp:TextBo x id="UserPass" runat="server" TextMode="Passw ord"></asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator2" runat="server" ControlToValida te="UserPass"
Display="Static " ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember" runat="server"> </asp:CheckBox>Re member credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginB tn_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]
<configuratio n>
<system.web>
<authorizatio n>
<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 1541
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*******@comc ast.net> wrote in message
news:ma******** ************@co mcast.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_Au thenticateReque st). 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.Us er)
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]
<configuratio n>
<appSettings>
<add key="MM_CONNECT ION_HANDLER_eOn Conn" value="default_ oledb.htm"
/>
<add key="MM_CONNECT ION_STRING_eOnC onn"
value="Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Inetp ub\wwwroot\eOn\ Database\eOn.md b;Persist Security Info=False"
/>
<add key="MM_CONNECT ION_DATABASETYP E_eOnConn" value="OleDb" />
<add key="MM_CONNECT ION_SCHEMA_eOnC onn" value="" />
<add key="MM_CONNECT ION_CATALOG_eOn Conn" value="" />
</appSettings>

<system.web>
<authenticati on mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All ">
<credentials passwordFormat= "Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorizatio n>
<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 FormsAuthentica tion.Authentica te(UserName.Tex t,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentica tion.RedirectFr omLoginPage(Use rName.Text,
Remember.Checke d)
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:TextBo x id="UserName"
runat="server"> </asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator1"
runat="server" ControlToValida te="UserName"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td>Password: </td>
<td><asp:TextBo x id="UserPass" runat="server"
TextMode="Passw ord"></asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator2"
runat="server" ControlToValida te="UserPass"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"> </asp:CheckBox>Re member credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginB tn_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]
<configuratio n>
<system.web>
<authorizatio n>
<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******@takem pis.com> wrote in message
news:%2******** ********@tk2msf tngp13.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*******@comc ast.net> wrote in message
news:ma******** ************@co mcast.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_Au thenticateReque st). 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.Us er)
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]
<configuratio n>
<appSettings>
<add key="MM_CONNECT ION_HANDLER_eOn Conn" value="default_ oledb.htm" />
<add key="MM_CONNECT ION_STRING_eOnC onn"
value="Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Inetp ub\wwwroot\eOn\ Database\eOn.md b;Persist Security Info=False" />
<add key="MM_CONNECT ION_DATABASETYP E_eOnConn" value="OleDb" />
<add key="MM_CONNECT ION_SCHEMA_eOnC onn" value="" />
<add key="MM_CONNECT ION_CATALOG_eOn Conn" value="" />
</appSettings>

<system.web>
<authenticati on mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All ">
<credentials passwordFormat= "Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorizatio n>
<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 FormsAuthentica tion.Authentica te(UserName.Tex t,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentica tion.RedirectFr omLoginPage(Use rName.Text,
Remember.Checke d)
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:TextBo x id="UserName"
runat="server"> </asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator1" runat="server" ControlToValida te="UserName"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td>Password: </td>
<td><asp:TextBo x id="UserPass" runat="server"
TextMode="Passw ord"></asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator2" runat="server" ControlToValida te="UserPass"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"> </asp:CheckBox>Re member credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginB tn_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]
<configuratio n>
<system.web>
<authorizatio n>
<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_Au thenticateReque st)"

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******@takem pis.com> wrote in message
news:%2******** ********@tk2msf tngp13.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*******@comc ast.net> wrote in message
news:ma******** ************@co mcast.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_Au thenticateReque st). 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.Us er)
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]
<configuratio n>
<appSettings>
<add key="MM_CONNECT ION_HANDLER_eOn Conn" value="default_ oledb.htm" />
<add key="MM_CONNECT ION_STRING_eOnC onn"
value="Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Inetp ub\wwwroot\eOn\ Database\eOn.md b;Persist Security Info=False" />
<add key="MM_CONNECT ION_DATABASETYP E_eOnConn" value="OleDb" />
<add key="MM_CONNECT ION_SCHEMA_eOnC onn" value="" />
<add key="MM_CONNECT ION_CATALOG_eOn Conn" value="" />
</appSettings>

<system.web>
<authenticati on mode="Forms">
<forms name=".CCAUTH" loginUrl="../login.aspx"
protection="All ">
<credentials passwordFormat= "Clear">
<user name="1" password="1" />
</credentials>
</forms>
</authentication>
<authorizatio n>
<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 FormsAuthentica tion.Authentica te(UserName.Tex t,
UserPass.Text) Then
' Return to the originally requested URL.
FormsAuthentica tion.RedirectFr omLoginPage(Use rName.Text,
Remember.Checke d)
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:TextBo x id="UserName"
runat="server"> </asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator1" runat="server" ControlToValida te="UserName"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td>Password: </td>
<td><asp:TextBo x id="UserPass" runat="server"
TextMode="Passw ord"></asp:TextBox></td>
<td><asp:Requir edFieldValidato r id="RequiredFie ldValidator2" runat="server" ControlToValida te="UserPass"
Display="Static "
ErrorMessage="* "></asp:RequiredFie ldValidator></td>
</tr>
<tr>
<td colspan="3"> <asp:CheckBox id="Remember"
runat="server"> </asp:CheckBox>Re member credentials?</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginB tn_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]
<configuratio n>
<system.web>
<authorizatio n>
<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
4135
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
1608
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
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9332
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8252
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.