惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 风的影

微服务 口试常见题 SQL 大数据查询如何进行优化? 事件和委托的区别 虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别 高并发的秒杀 C#算法 口试C#概念 口试Linq题 口试大数据及大并发问题 笔试题多线程 笔试代码考查 SQL笔试基础 口试基础 笔试基础知识 Asp.net项目从Vs2003转换到Vs2005的常见问题大全及解决方法 烦人的网页iframe去除 经典sql注入教程 C# 相当于ASP里Eval中的计算公式的方法(超简单的方法)
自己写的后台静态权限验证类
风的影 · 2007-07-09 · via 博客园 - 风的影

用于权限是复选框选择的后台权限验证
using System;

namespace baitang.util
{
 /// <summary>
 /// 验证登陆。
 /// </summary>
 public class CheckGrade
 {
  public CheckGrade()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }
  /// <summary>
  /// 验证是否登陆及权限
  /// </summary>
  /// <param name="str">本页需要的权限</param>
  public static string IsGrade(String str)
  {
   System.Console.Write(System.Web.HttpContext.Current.Session["Poplist"]);
   if(System.Web.HttpContext.Current.Session["Poplist"]==null)
   {
    return "<script>alert('对不起,您还未登陆或已超时,请重新登陆!');window.location.href='/Manager/exit.aspx';</script>";
   }
   else
   {
    if(System.Web.HttpContext.Current.Session["Poplist"].ToString().IndexOf(str)<0)
    {
     return "<script>alert('对不起,您没有执行此操作的权限');history.go(-1);</script>";
    }
   }
   return "";
  }
 }
}

后台权限管理页例:
                    <input id="G0101" type="checkbox" value="[G0101]" name="Grade" <%if(PopListTmp.IndexOf("[G0101]") >= 0){Response.Write("Checked");} %> />新闻分类</td>
                <td style="width: 100px"><input id="G0102" type="checkbox" value="[G0102]" name="Grade" <%if(PopListTmp.IndexOf("[G0102]") >= 0){Response.Write("Checked");} %> />新闻列表</td>
                <td style="width: 100px"><input id="G0103" type="checkbox" value="[G0103]" name="Grade" <%if(PopListTmp.IndexOf("[G0103]") >= 0){Response.Write("Checked");} %> />最新活动</td>

这里权限数据两边加中括号的原因:
以前用纯数据表示权限,权限1到20的话,用上面的权限判断方法,1,10,11在IndexOf判断上会出问题,于是变成了[1],[10],[11],这样便于判断,当然上面以字母G打头而且数据长度相同就不会出现这种问题了,但写习惯了,也加了[],呵呵