教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 asp.net Substitution控件MethodName获取Session失败的解决办法

asp.net Substitution控件MethodName获取Session失败的解决办法

发布时间:2018-09-28   编辑:jiaochengji.com
教程集为您提供asp.net Substitution控件MethodName获取Session失败的解决办法 等资源,欢迎您收藏本站,我们将为您提供最新的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验证码验证失败的原因以及解决办法

[关闭]
~ ~