去FAQ里看一下,有个相关的帖子。
解决方案 »
- 左边一个TREEVIEW 点击节点,怎么把页加载进来?
- 一个ASP.net下无法提交表单的问题
- █㊣小政哥㊣█急问HtmlEditor3.1, 如何让输入的HTML标记文本原样显示啊?现在的结果是会自动翻译成HTML标记显示的效果
- 如何把用window.open打开的webForm的最大化按钮最小化按钮屏蔽掉??急!!
- 怎么知道一个textbox中是整数!!!
- DataGrid无绑定时,如何显示DataGrid标头?
- 页面刷新时,怎样保存密码框中的密码阿?
- 大家评评北京要求外地人办暂住证是否违法?(斑竹手下留情)
- 怎么才能使Dropdownlist的SelectedIndexChanged事件里的代码执行呢?
- 讨论一下页面级变量?
- DataGrid/DataList编辑模式嵌套组件问题,虚心求教?
- 大侠们帮帮忙,郁闷之至:首次运行非常正常,刷新页面或再次进入此asp.net页面时老报错。
<forms name=".ASPXCOOKIEDEMO" loginUrl="login.aspx" protection="all" timeout="30" path="/">
<!-- protection="[All|None|Encryption|Validation]" -->
</forms>
</authentication
<authentication mode="Forms">
<forms name=".ASPXCOOKIEDEMO" loginUrl="login.aspx" protection="all" timeout="30" path="/">
<!-- protection="[All|None|Encryption|Validation]" -->
</forms>
</authentication
这样的话并不是队community目录加验证吧
我不知道怎么作登陆
比如我想登陆成功直接跳转的页面是/community/main.aspx
我怎么作
我用如下方法
结果还是返回login.aspx 无法访问/community/main.aspx
if(DrPwd == pwd) { Session["logname"] = userid; Session["logid"] = DrID; FormsAuthentication.RedirectFromLoginPage(userid,true); Response.Redirect("community/main.aspx");}
求助
建议你看看 清华的那本叫 asp.net安全高级编程,具体叫什么名字忘了。
http://www.csdn.net/develop/article/18/18958.shtm
可是我的/community/下的web.config如何设置呢
/不需要验证
/community需要
private void Button1_Click(object sender, System.EventArgs e)
{
string user = this.uid.Text; //读取用户名
string password = this.upwd.Text; //读取密码
if(Confirm(user,password) == true) //confirm方法用来验证用户合法性的
{
//string userRoles = UserToRole(user); //调用UserToRole方法来获取role字符串
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket (1,user,DateTime.Now,DateTime.Now.AddMinutes(30), false,"/") ; //建立身份验证票对象
string HashTicket = FormsAuthentication.Encrypt (Ticket) ; //加密序列化验证票为字符串
HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName,HashTicket) ;
//生成Cookie
Context.Response.Cookies.Add (UserCookie) ; //输出Cookie
Context.Response.Redirect("./community/main.aspx") ; // 重定向到用户申请的初始页面 }
else
{
// 用户身份未被确认时的代码
Response.Write("<script language=\"javascript\">alert('用户身份验证失败,密码错误或者没有这个用户!')</script>");
}
}
如下就可以:
<location path="community">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
是不是就是没有验证的用户全部拒绝???
我去试一下
* 所有用戶
Attention:
切記最好不用以下語句,因為他會覆蓋你的驗証cookie
FormsAuthentication.RedirectFromLoginPage(userid,true); Response.Redirect("community/main.aspx");
Istend that
string returnUrl=RequestString["returnurl"];
if(returnUrl==null || string.empty)
returnurl=""; //specify your url that you want to go
A Example for a folder of admin
<configuration> <system.web>
<!-- This setting is configured so that only authenticated users can visit any of the
pages in the Admin directory -->
<authorization>
<allow roles="Forum-Administrators" />
<deny users="*" />
</authorization>
</system.web></configuration>