.NET 2.0: asp:Login

R

R.A.M.

Hello
Could you help a beginner with login implementation using asp:Login
(.NET 2.0).
I have in Web.config:
<authentication mode="Forms">
<forms name="Demo.NET" loginUrl="Default.aspx" />
</authentication>
<authorization>
<allow users="demo"/>
<deny users="*"/>
</authorization>
In Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="DefaultPage" %>
...
<form id="LoginForm" method="post" action="Menu.aspx"
style="vertical-align: middle;" runat="server">
<asp:Login ID="DemoLogin" runat="server"
DestinationPageUrl="Menu.aspx"
TitleText="Logging in"
UserName="demo" UserNameLabelText="User"
PasswordLabelText="Password"
PasswordRequiredErrorMessage="Password required."
LoginButtonText="Login" LoginButtonType="Button"
RememberMeSet="true" RememberMeText="Remember me."
InstructionText="Enter: demo/demo."
FailureText="Failure. Try again."
OnLoggingIn="OnLoggingIn" />
</form>
...
And in Default.aspx.cs I have:
...
public partial class DefaultPage : System.Web.UI.Page
{
public void OnLoggingIn(object sender,
System.Web.UI.WebControls.LoginCancelEventArgs e)
{
if (DemoLogin.Password != "demo")
e.Cancel = true;
}
}
I don't understand why after enetring demo/demo on Default page I
receive failure message; OnLoggingIn() passes correctly.
How to correct the problem?
Thank you very much.
/RAM/
 
E

Erik Funkenbusch

I don't understand why after enetring demo/demo on Default page I
receive failure message; OnLoggingIn() passes correctly.
How to correct the problem?
Thank you very much.

I've already told you once. Don't use OnLoggingIn. Use OnAuthenticate
instead.
 
R

R.A.M.

THANK YOU. I DID IT - IT WORKS FINE.
NO, THERE'S A PROBLEM.
After pressing Login button by the user, URL is changed to:
http://localhost:1047/Demo.NET/Default.aspx?ReturnUrl=/Demo.NET/Menu.aspx
(which does not work), while I expected:
http://localhost:1047/Demo.NET/Menu.aspx
(a have assigned to login control DestinationPageUrl = "Menu.aspx").
Could you explain me what's going on?
The user is not moved to Menu.aspx, so application doesn't work.
Could you help me please?
THANX A LOT.
/RAM/
 
E

Erik Funkenbusch

NO, THERE'S A PROBLEM.
After pressing Login button by the user, URL is changed to:
http://localhost:1047/Demo.NET/Default.aspx?ReturnUrl=/Demo.NET/Menu.aspx
(which does not work), while I expected:
http://localhost:1047/Demo.NET/Menu.aspx
(a have assigned to login control DestinationPageUrl = "Menu.aspx").
Could you explain me what's going on?
The user is not moved to Menu.aspx, so application doesn't work.
Could you help me please?
THANX A LOT.
/RAM/

You have not defined an authorization section in your web config to give
access to authenitcated users.

You need somethign like this:

<authorization>
<deny users="?" />
</authorization>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top