PDA

View Full Version : اتوریز کاربر



Asad.Safari
جمعه 09 مرداد 1383, 12:47 عصر
با سلام
من می خام صفحه لوگین اوتریز کاربر بسازم
کد صفحه لوگین:


<%@ import namespace="system.data"%>
<%@ import namespace="system.data.sqlclient"%>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ import namespace="system.web.security" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<style type="text/css">
<!--
.style1 {
font-family: Tahoma;
font-size: x-small;
}
-->
</style>
</head>
<body>
<form runat="server" method="post">
<table width="200" border="0" align="center" bgcolor="#C0CED8">
<tr>
<td><asp:TextBox runat="server" ID="txtname"></asp:TextBox></td>
<td><div align="right"><span class="style1">:<span lang="fa">نام</span></span></div></td>
</tr>
<tr>
<td><asp:TextBox runat="server" ID="txtpassword"></asp:TextBox></td>
<td><div align="right"><span class="style1">:رمز عبور </span></div></td>
</tr>
<tr>
<td><center>
<p><asp:Button runat="server" ID="btnlogin" Text="ورود" OnClick="login">
</asp:Button></p>
</center></td>
<td><asp:checkbox id="persist" runat="server"></asp:checkbox></td>
</tr>
</table>
<p align="center"><a href="Search.aspx"><span class="style1">اگر رمز عبور خود را فراموش کردید اینجا کلیک کنید</span></a></p>
</form>
</body>
</html>
<script runat="server" language="vb">
sub login(sender as object,e as eventargs)
dim strconnection as string="server=(LOCAL);database=test;integrated security=true;"
dim objconnection as new sqlconnection(strconnection)
dim strsql as string="select password from Register where name = '" & txtname.text & "'"
dim objcommand as new sqlcommand(strsql,objconnection)
objconnection.open()
dim dr as sqldatareader=objcommand.executereader()
if dr.read()
if dr("password").tostring=txtpassword.text
FormsAuthorization.redirectFormLoginPage(name.Valu e._persist.Checked)
else
response.Write("password not found")
end if
end if
dr.close()
end sub
</script>
<p> </p>


کد web.config


<!-- Web.config -->
<configuration>
<system.web>
<authentication mode= "Forms">
<forms name="formsauth" loginUrl="Login.aspx" protection="All" timeout="60"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>


error:


Name 'FormsAuthorization' is not declared



من چی کار کنم درست شه!!

باتشکر

MSYNK
دوشنبه 12 مرداد 1383, 16:08 عصر
با سلام
فکر کنم اینجوری:

Imports System.Web.Security
البته برای کدنویسی به روش Code Behinde!
برای روش شما(فکر کنم بهش میگن inline):

<%@ Import Namespace="System.Web.Security" %>
با تشکر.