asp.net Substitution控件MethodName获取Session失败的解决办法
substitution是对缓存页面实现动态显示部分内容的控件,使用方法:在后台页面添加静态方法,private static string methodname(httpcontext context),经典的用法是动态显示的是当前的登录用户名字(非登录用户显示其他的)。
<blockquote>private static string methodname(httpcontext context)
{
return convert.tostring(context.session["username"]);
}
</blockquote>
运行时会有异常。
解决方法:就像httphandler 不能取session的解决方法一样,将目标页面继承
<blockquote>system.web.sessionstate.irequiressessionstate接口,</blockquote>解决!
您可能感兴趣的文章:
asp.net Substitution控件MethodName获取Session失败的解决办法
Asp.net 默认配置下,Session莫名丢失的原因及解决办法
java中使用Cookie替代Session解决跨域Session失效问题
windows10升级9789失败如何处理?win10升级9879失败解决方法
PHP session实现跨子域的几种办法
codeigniter与swfupload整合解决方案
php session跨域跨服务器的解决方法分享
asp.net Session丢失的解决方法
php中kindeditor多图上传session丢失问题解决
TP6验证码验证失败的原因以及解决办法