<deny users="?" />
这行去掉再试试。
这行去掉再试试。
解决方案 »
- 【求救大召唤】:在VS上调试没问题,但放到IIS上就崩坏了
- 请教高手:多台机器同时访问同一台服务器,数据丢失问题。。
- GridView+sql多次查询问题
- ajax能同时返回一个xml和一个string
- 有人做过跨站登录吗?在A站输入账号和密码,到B站登录,然后就呆在B站了。
- 拜托各位,我在使用visual studio.net时发生了恐怖的事情
- 求Base64转换代码
- 没有分了,请大家推荐一个三层结构的例子
- DropDownList关联不刷新问题!
- 在页面刷新后如何将页面定位到刷新前的位置
- 求解:win2003 + iis 6.0 局域网内不能发布 网站
- ASP.NET 如何实现ListView控件功能
这行是禁止匿名用户的, 不应该去吧,
究竟该怎样设置阿?
<deny users="?" />中去掉
<allow users="*" />另外再加上下面这段,否则你的登录页也无法访问:
<location path="login.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<allow users="*" />
private void Button1_Click(object sender, System.EventArgs e)
{
string dsn = ConfigurationSettings.AppSettings["conStr"];
string strSelect = "select * from Users where userid=@txtName and password=@txtPwd";
SqlConnection myCon = new SqlConnection(dsn);
SqlCommand myCmd = new SqlCommand(strSelect,myCon);
myCmd.Parameters.Add("@txtName",SqlDbType.VarChar,50);
myCmd.Parameters["@txtName"].Value = txtName.Text;
myCmd.Parameters.Add("@txtPwd",SqlDbType.VarChar,20);
myCmd.Parameters["@txtPwd"].Value = txtPwd.Text;
myCon.Open();
SqlDataReader dr = myCmd.ExecuteReader();
if (dr.Read())
{
Session["uid"] = dr["userid"].ToString();
Page.Response.Redirect("main.aspx");
}
else
{
lblMsg.Text = "用户" + txtName.Text + "不存在";
}
myCon.Close();
}
在没有配置web.config时是正常的
{
Session["uid"] = dr["userid"].ToString();
Page.Response.Redirect("main.aspx");
}改为:if (dr.Read())
{
Session["uid"] = dr["userid"].ToString();
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtName.Text,false);
}