網站首頁 編程語言 正文
- 在后臺線程里訪問導致System.Web.HttpContext.Current==null,從而引發了報錯
- 去查看了下 官方文檔,解釋是 在線程中訪問,未定義的現象
https://docs.microsoft.com/zh-cn/dotnet/api/system.web.httpcontext?view=netframework-4.8
解決方案如下
public static string GetPath(string path)
{
if (HttpContext.Current != null)
{
return HttpContext.Current.Server.MapPath(path);//有http請求
}
else
{
return System.Web.HttpRuntime.AppDomainAppPath.ToString()+ path;
}
}
原文鏈接:https://blog.csdn.net/qq_38110067/article/details/125617194
相關推薦
- 2023-01-23 Python+Qt身體特征識別人數統計源碼窗體程序(使用步驟)_python
- 2023-03-13 Python實現柵欄密碼的加密解密方法詳解_python
- 2022-10-15 C++?accumulate函數詳細介紹和具體案例_C 語言
- 2022-06-06 delete from xx_table(刪除全表數據)對應的binlog是怎么記錄的?
- 2022-11-23 Golang?官方依賴注入工具wire示例詳解_Golang
- 2022-04-02 C語言對冒泡排序進行升級介紹_C 語言
- 2023-07-14 react 利用插件react-draggable實現拖拽功能
- 2022-06-25 Python二維列表的創建、轉換以及訪問詳解_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支