多用户身份FORM验证问题 用.net本身提供的membership管理可以轻松达到你的要求 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 write cookie:HttpCookie cookie1 = new HttpCookie("UserID");cookie1.Value = sdr["UserID"].ToString();Response.AppendCookie(cookie1);read cookie:string UserID;UserID= Request.Cookies["UserID"].Value.ToString(); 以下我自己写的代码行吗? SqlConnection con=DB.con(); SqlCommand cmd=new SqlCommand("UserLogin",con); cmd.CommandType=CommandType.StoredProcedure; SqlParameter Uname=new SqlParameter("@UName",SqlDbType.NVarChar,16); Uname.Value=TextBox1.Text; cmd.Parameters.Add(Uname); SqlParameter Pword=new SqlParameter("@PWord",SqlDbType.NVarChar,16); Pword.Value=TextBox2.Text; cmd.Parameters.Add(Pword); try { con.Open(); SqlDataReader dr=cmd.ExecuteReader(); if (dr.Read()) { Response.Cookies["id"].Value=dr["uid"].ToString(); dr.Close(); FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,false); } } catch(Exception ex) { Response.Write (ex.Message); } finally { con.Close(); }符合标准吗? 以下是我webconfig文件设置 <authentication mode="Forms"> <forms loginUrl="Login.aspx" name="AuthCookie" timeout="60" path="/"/> </authentication> <authorization> <deny users="?" /> <!-- 允许所有用户 --> </authorization> 使用Forms的roles,另外1.1中不要使用RedirectFromLoginPage。有BUG。会产生临时票据,里面的false和true会导致cookies的永久性。 贴了好几天了,就是没一个全面的解答,CSDN怎么了?老大们都怎么了? 如果你的用户数相对固定,不是需要注册的那种.而且没有角色的话,你可以这样 <authentication mode="Forms"> <forms defaultUrl="admin/" loginUrl="login/" name="santuchildbike" path="/" protection="All" timeout="60"> <credentials passwordFormat ="MD5"> <user name ="santuchildbike" password ="5A0D7C31E8E266215461AF8408E4DB2F"/> <user name="" password=""/> </credentials> </forms> </authentication>可以加任意多个 <user name="" password=""/>节点.这样实现起来方便多了 ASP.NET中有什么可以做申请单,请假单等这种单据么 各位大侠们能不能给推荐些能下载用户控件的网站 数据库导出格式化 缓存初级问题。关于缓存DataSet数据的。 请问如何绑定数据到一个列上,显示的数据是另一个表中的数据 请问如何在页面间传递数组 多个字符串组成的Cookie怎样分别提取每一部分??? JS打开一个新窗口 并马上将它隐藏起来 请问怎么设定datagrid里的字体? entity framework问题,用事务添加实体,获取已添加实体的自增键值 XML不能装载 如何用WEB指定上传服务器
HttpCookie cookie1 = new HttpCookie("UserID");
cookie1.Value = sdr["UserID"].ToString();
Response.AppendCookie(cookie1);read cookie:
string UserID;
UserID= Request.Cookies["UserID"].Value.ToString();
SqlConnection con=DB.con();
SqlCommand cmd=new SqlCommand("UserLogin",con);
cmd.CommandType=CommandType.StoredProcedure; SqlParameter Uname=new SqlParameter("@UName",SqlDbType.NVarChar,16);
Uname.Value=TextBox1.Text;
cmd.Parameters.Add(Uname); SqlParameter Pword=new SqlParameter("@PWord",SqlDbType.NVarChar,16);
Pword.Value=TextBox2.Text;
cmd.Parameters.Add(Pword); try
{
con.Open();
SqlDataReader dr=cmd.ExecuteReader();
if (dr.Read())
{
Response.Cookies["id"].Value=dr["uid"].ToString();
dr.Close();
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,false);
}
}
catch(Exception ex)
{
Response.Write (ex.Message);
}
finally
{
con.Close();
}符合标准吗?
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="AuthCookie" timeout="60" path="/"/>
</authentication>
<authorization>
<deny users="?" /> <!-- 允许所有用户 -->
</authorization>
<forms defaultUrl="admin/" loginUrl="login/" name="santuchildbike" path="/" protection="All" timeout="60">
<credentials passwordFormat ="MD5">
<user name ="santuchildbike" password ="5A0D7C31E8E266215461AF8408E4DB2F"/>
<user name="" password=""/>
</credentials>
</forms>
</authentication>
可以加任意多个 <user name="" password=""/>
节点.这样实现起来方便多了