线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
来源:互联网 发布:unity3d 多人在线 编辑:程序博客网 时间:2024/05/18 16:13
在多线程里面使用HttpContext.Current,HttpContext.Current是得到null的.
所以在线程调用方法,方法中类里面的System.Web.HttpContext.Current.Server.MapPath() 获取不到对象。
所以在线程调用方法,方法中类里面的System.Web.HttpContext.Current.Server.MapPath() 获取不到对象。
应该这么用:
public static string MapPath(string strPath) { if (HttpContext.Current != null) { return HttpContext.Current.Server.MapPath(strPath); } else //非web程序引用 { strPath = strPath.Replace("/", "\\"); if (strPath.StartsWith("\\")) { //strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\'); strPath = strPath.TrimStart('\\'); } return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); } }
- 线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
- System.Web.HttpContext.Current.Server.MapPath()
- 线程Thread调用时System.Web.HttpContext.Current为NULL
- System.Web.HttpContext.Current是什么
- 慎用System.Web.HttpContext.Current
- System.Web.HttpContext.Current.Cache 与System.Web.HttpRuntime.Cache
- HttpContext.Current.Server.MapPath("") 未将对象设置到引用的实例异常。
- System.Web.HttpContext.Current.Session为NULL值的问题?
- ASP.NET System.Web.HttpContext类Current属性 的运用
- ASP.NET System.Web.HttpContext类Current属性
- System.Web.HttpContext.Current.Session获取值出错
- 关于System.Web.HttpContext.Current.Session 为 null的问题
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session获取值出错
- 线程编程中用到HttpContext.Current的方法封装
- 线程编程中用到HttpContext.Current的方法封装
- System.Web.HttpContext.Current.Cache和System.Web.HttpRuntime.Cache有什么区别?
- System.Web.HttpContext.Current.Cache与System.Web.HttpRuntime.Cache指向同一个引用
- XML 与 XPATH 简介
- 线程的停止
- sqlserver 派生表
- Android Hierarchy Viewer
- 搜索可用的google的IP
- 线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
- 更改linux2.6.12内核的启动界面
- 高可用方案之脑裂问题探讨
- 中国企业家的自我救赎
- 常用函数 c++
- 【+】Linux Socket编程
- Http Status Code/http响应状态码
- 分享30个非常实用的游戏和应用源码
- Unity简介