我的网站分几级权限:前台都可以浏览,后台(Manage目录)只有会员才可以(管理员包括在里面),然后在后台的网站信息设置页面(Manage/WebSet.aspx)里,要求只有管理员才能进.目前后台是用的Forms身份验证,相关代码如下:
<authentication mode="Forms">
<forms name="ChrisLiu" loginUrl="Login.aspx" protection="All" timeout="30" path="/" />
</authentication><authorization>
<allow users="*" />
</authorization><location path="Manage">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>请问怎么办???还用Forms验证来设置Manage下的WebSet目录,可以吗???.我不想再用Session或Cookie了(麻烦死了),却找不到解法.
<authentication mode="Forms">
<forms name="ChrisLiu" loginUrl="Login.aspx" protection="All" timeout="30" path="/" />
</authentication><authorization>
<allow users="*" />
</authorization><location path="Manage">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>请问怎么办???还用Forms验证来设置Manage下的WebSet目录,可以吗???.我不想再用Session或Cookie了(麻烦死了),却找不到解法.
解决方案 »
- 孟子:创建表头固定,表体可滚动的GridView 在AJAX应用中问题???
- 如何设置外键
- datagridview中如何添加删除修改数据
- 页面传送路径值如何实现?
- CustomValidator 的error message 为什么没有在ValidationSummary 上显示出来?
- 就40分了!用户控件中动态创建服务器端控件的问题!
- “GridView1.Rows[e.RowIndex].Cells[0].Controls[0]”引发了“System.ArgumentOutOfRangeEx
- 关于表格节点的问题
- 谁遇到在自定义服务器控件时,CreateChildControls()方法执行多次的情况,若有请告知出现的可能性。最好举一个例子。
- 请教高手:DataGrid里对汉字排序怎么不是按汉字拼音排序的?
- 求一算法。谢谢
- 关于Infragistics里的一个问题。
<forms name="ChrisLiu" loginUrl="Login.aspx" protection="All" timeout="30" path="/" >
</forms>
<credentials passwordFormat="Clear">
<user name="admin1" password="pwd1" />
<user name="admin2" password="pwd2" />
</credentials>
</authentication>
<location path="Manage/WebSet.aspx">
<system.web>
<authorization>
<allow roles="admin" />
<deny users="?" />
</authorization>
</system.web>
</location>然后在Global.asax.cs中的Application_AuthenticateRequest事件中写如下代码:
// 映射用户的权限 [3/5/2005]
HttpApplication app = (HttpApplication)sender;
if (app.Request.IsAuthenticated &&
app.User.Identity is FormsIdentity)// 如果请求已经通过验证,并且验证模式是“窗体验证" [3/5/2005]
{
FormsIdentity indentity = (FormsIdentity)app.User.Identity; // 得到用户的角色 [3/5/2005]
DataSet ds = BusinessRules.sysMana.sysManaRules.GetPermissionModules(indentity.Name);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach(DataRow dr in ds.Tables[0].Rows)
{
sb.Append(dr["RoleName"].ToString() + ",");
}
string[] roles = sb.ToString().Split(new char[] {','});
if (roles != null)
{
app.Context.User = new GenericPrincipal(indentity, roles);
string strURL = this.Request.ApplicationPath;
}
}