pre { /*控制代码不换行*/ white-space: pre; word-wrap: normal; }

AjaxPro使用Session出错(AjaxPro "Session"引发了"System.NullReferenceException"类型的异常)

关于在ASP.NET如何使用AjaxPro,这里就不多说了,先看代码:

    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    
public string btnNextZX(string data)
    {
        
        StringBuilder zx_Ret 
= new StringBuilder();
        Hashtable hash 
= (Hashtable)Session["jgd_data"];
    

注意:这里排除Session中没有["jgd_data"]这个数据而引起的出错,当然即使不存在也报的并不是如下的错误:

很奇怪!我明明加了如下代码啊!!

[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]



解决办法:

将如下代码行:

Hashtable hash = (Hashtable)Session["jgd_data"];

替换成如下代码:

Hashtable hash = (Hashtable)HttpContext.Current.Session["jgd_data"];


执行OK!!

posted @ 2011-08-17 07:23  monkey's  阅读(662)  评论(0)    收藏  举报