一个非常棘手的问题 System.Web.HttpContext.Current==null
由于要使用定时器,所以在Application_Start加入他。
而由定时器触发的线程 因为没有request 所以System.Web.HttpContext.Current就=null
而我的代码中需要用到System.Web.HttpContext.Current.Server.HtmlEncode,所以我将System.Web.HttpContext.Current.Server替换为System.Web.HttpServerUtility,可是没有HtmlEncode函数
System.Web.HttpServerUtility ser=new System.Web.HttpServerUtility();//也不行,提示没有构造函数
System.Web.HttpServerUtility ser; //也不行,提示ser没有赋值。。
我郁闷惨了,怎么办啊?