簡體   English   中英

HttpContext.Current.Request.Url.AbsolutePath在global.asax文件中生成錯誤

[英]HttpContext.Current.Request.Url.AbsolutePath generate error in global.asax file

我正在使用其中一個函數中的global.asax文件中的HttpContext.Current.Request.Url.AbsolutePath來從數據庫獲取頁面相關的詳細信息,但它失敗並出現以下錯誤。

`string _result = Helper.GetPageDetails( HttpContext.Current.Request.Url.AbsolutePath);`

我可以在這里使用這個HttpContext.Current.Request.Url.AbsolutePath我需要獲取URL的absolutePath,我得到以下錯誤

An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code

Additional information: Request is not available in this context

我在try {}中抓住了這個,我得到以下錯誤消息詳細信息

ex = {"Request is not available in this context"}

這意味着沒有與當前方法調用(線程)相關聯的請求。 我猜你從一個單獨的線程調用HttpContext.Current.Request.Url.AbsolutePath而不是請求中的一個。 沒有進一步的信息,我可以說

在global.asax中使用

Context.Request

作為替代品

HttpContext.Current.Request

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM