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之间的管 ...
随机推荐
- 基于Python+Django的Kubernetes集群管理平台
➠更多技术干货请戳:听云博客 时至今日,接触kubernetes也有一段时间了,而我们的大部分业务也已经稳定地运行在不同规模的kubernetes集群上,不得不说,无论是从应用部署.迭代,还是从资源调 ...
- 基于jquery实现图片拖动和曲线拖放
功能:图片的拖动.曲线的拖放和绘制 一. 准备工作 1. 点击此下载相关的文档 二. 在浏览器中运行 dragDrop.html 文件,即可看到效果 三. 效果图
- 升级 python 2.6.6 系统到 2.7.10 版本
CentOS 6 系统默认 Python 版本是:2.6.6 平时在使用中遇到很多的库要求是 2.7.x 版本的库,比如使用 ConfigParser 库,在 2.6 版本库就不支持没有 value ...
- Ubuntu 14.04 LTS下安装Google Chrome浏览器
在Ubuntu 14.04下安装Google Chrome浏览器非常简单,只要到Chrome的网站下载Deb安装包并进行安装即可.当然你也可以使用APT软件包管理器来安装Google Chrome浏览 ...
- .net core ClaimsPrincipal Class
hClaimsPrincipal Class ttps://msdn.microsoft.com/en-us/library/system.identitymodel.services.claimsp ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- cg数据类型
Cg 支持7 种基本的数据类型:1. float,32 位浮点数据,一个符号位.浮点数据类型被所有的profile 支持(但是DirectX8 pixel profiles 在一些操作中降低了浮点数的 ...
- ns3 print 丢包内容的两种方法
1.方法一enable ascii print AsciiTraceHelper ascii; pointToPoint.EnableAsciiAll (ascii.CreateFileStream ...
- PHP基础语法
PHP:超级文本预处理器一,PHP的四对标记 <?php ?> <script language="php"> <script> ...
- [LeetCode] Basic Calculator 基本计算器
Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...