IRequiresSessionState接口控制
using System;
using System.Diagnostics;
using System.Reflection;
using System.Web.SessionState; namespace Ztest
{
public class Program: IRequiresSessionState
{
public static void Main(string[] args)
{
try
{
if (Test.Current.session == null)
{
Console.WriteLine("没有继承IRequiresSessionState");
}
else
{
Console.WriteLine(Test.Current.session);
}
}
catch (Exception ex)
{
}
Console.ReadLine();
}
}
public class Test
{
private Test()
{
Type basetype = typeof(IRequiresSessionState);
StackTrace trace = new StackTrace();
int i = 0;
Type type;
while (true)
{
///找到外层第一个调用类
MethodBase methodName = trace.GetFrame(i).GetMethod();
type = methodName.ReflectedType;
if (type != typeof(Test))
{
break;
}
i++;
} Boolean key = basetype.IsAssignableFrom(type);
if (key)
{
session = _m;
}
else
{
session = null;
}
}
private static Test _Current;
private string _m = "当前类实现了IRequiresSessionState";
/// <summary>
/// 模拟session
/// </summary>
public Object session { get; set; }
public static Test Current
{
get
{
return get();
}
set
{
Current = value;
}
}
private static Test get()
{
if (_Current == null)
{
_Current = new Test(); }
return _Current;
}
} }
IRequiresSessionState接口控制的更多相关文章
- HttpHandler和ashx要实现IRequiresSessionState接口才能访问Session信息(转载)
通常我们经常,通过session判定用户是否登录.还有一些临时的.重要的数据也尝尝存放在Session中. 在页面我们很容易的得到Session的值,但在类中就会遇到一些问题.也知道通过下面的方法得到 ...
- CAN-bus接口控制实验
CAN-bus接口控制实验 2016-04-12 20:38:41来源: eefocus 关键字:CAN bus 接口控制 收藏 评论(0) 分享到 微博 QQ 微信 LinkedIn 一.实 ...
- sama5 kio接口控制
//example #include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <str ...
- 在ashx文件中制作验证码(使用session要继承IRequiresSessionState)
必须继承System.Web.SessionState.IRequiresSessionState接口,才能实现Session读写! System.Web.SessionState的一些接口 IRea ...
- Asp.net下使用HttpModule模拟Filter,实现权限控制
在asp.net中,我们为了防止用户直接从Url中访问指定的页面而绕过登录验证,需要给每个页面加上验证,或者是在模板页中加上验证.如果说项目比较大的话,添加验证是一件令人抓狂的事情,本次,我就跟大家分 ...
- 【转载】关于Alipay支付宝接口(Java版)
转载自:http://blog.163.com/lai_chao/blog/static/70340789201412724619514/ 1.alipay 双功能支付简介 2.alipay 提交支付 ...
- 在一般处理文件中访问Session需要添加IRequiresSessionState(转载)
原文:http://blog.csdn.net/cdsnaspnet/article/details/5695625s 通常我们经常,通过session判定用户是否登录.还有一些临时的.重要的数据也尝 ...
- (二)再议MII、RMII、GMII接口
概述: MII (Media Independent Interface(介质无关接口)或称为媒体独立接口,它是IEEE-802.3定义的以太网行业标准.它包括一个数据接口和一个MAC ...
- 61.MII、RMII、GMII接口的详细介绍
概述: MII (Media Independent Interface(介质无关接口)或称为媒体独立接口,它是IEEE-802.3定义的以太网行业标准.它包括一个数据接口和一个MAC和PHY之间的管 ...
随机推荐
- 基于InstallShield2013LimitedEdition的安装包制作
在VS2012之前,我们做安装包一般都是使用VS自带的安装包制作工具来创建安装包的,VS2012.VS2013以后,微软把这个去掉,集成使用了InstallShield进行安装包的制作了,虽然思路差不 ...
- php Zend Opcache,xcache,eAccelerator缓存优化详解(具体根据个人需要选择其一即可,功能都一样切勿重复选择)
载入 XCache 模块 引用 ;; 安装成 zend extension (推荐), 路径一般是 "$extension_dir/xcache.so" zend_extensio ...
- HTML中使图片居中显示
注:imageId为图片id<style type="text/css"> #imageId{ display:block; position:relative; ma ...
- ajax请求成功后打开新开窗口(window.open())被拦截的解决方法
问题:今天在做项目时需要在ajax请求成功后打开一个新的窗口,此时遇到浏览拦截了新窗口的问题,尝试在ajax 回调函数中模拟执行 click 或者 submit 等用户行为(trigger('clic ...
- codegate-quals-2013-vuln100
最近想多看看题目积累些经验, -------- 程序分析 64位,保护措施都没开 gdb-peda$ checksec CANARY : disabled FORTIFY : disabled NX ...
- JS--轻松设置获取表单数据
接触过Angularjs的都知道,ng支持双向绑定,我们可以轻轻松松的通过ngModel将我们的值绑定到界面,当修改了值提交表单的时候不需要再重新通过ID去重新抓取输入框信息了.那对于我们开发前台网站 ...
- Linux shell redirect
Learn much from here Learn much from here
- [LeetCode] Shortest Word Distance 最短单词距离
Given a list of words and two words word1 and word2, return the shortest distance between these two ...
- java 分页功能
1.分页工具类 package com.bw.shop.util; import java.util.List; import com.sun.org.apache.regexp.internal.r ...
- 阿里云VPS服务器,ROS内网穿透
Aliyun Windows Server 2008 R2中建立vpn服务器,ros中使用pptp拨号连接 2.在Aliyun服务器中,修改hosts,将内网分配的ip映射到指定的域名,在Aliyun ...