Salve, ho questo codice che uso in asp net 2.0 c#:
login.aspx
e il file login.aspx.cs
Ora chiedo ad voi come faccio ad implementarlo dentro ad questo tutorial:
[url]http://ondotnet.com/pub/a/dotnet/2003/01/06/formsauthp1.html[/url]
e vi incollo qui i codici:
<%@ Import Namespace="System.Web.Security " %>
<html>
<script language="C#" runat=server>
void Login_Click(Object sender, EventArgs E)
{
// authenticate user: this sample accepts only one user with
// a name of [email]username@domain.com[/email] and a password of 'password'
if ((UserEmail.Value == "username@domain.com") &&
(UserPass.Value == "password"))
{
FormsAuthentication.RedirectFromLoginPage(UserEmail.Value,
PersistCookie.Checked);
}
else
{
lblResults.Text = "Invalid Credentials: Please try again";
}
}
</script>
<body>
<form runat="server">
<h3>Login Page</h3>
<hr>
Email:<input id="UserEmail" type="text" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="UserEmail"
Display="Static"
ErrorMessage="*"
runat="server"/>
<p>Password:<input id="UserPass"
type="password"
runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="UserPass"
Display="Static"
ErrorMessage="*"
runat="server"/>
<p>Persistent Cookie:<ASP:CheckBox id="PersistCookie"
runat="server" />
<p><asp:button id="cmdLogin"
text="Login"
OnClick="Login_Click"
runat="server"/>
<p><asp:Label id="lblResults"
ForeColor="red"
Font-Size="10"
runat="server" />
</form>
</body>
</html>
Mi date una mano ad implementarlo,
e fare dei web.config per le tre livelli "user,Manager,Admin";
vi ringrazio molto.
Aspetto risposte.
Grazie.