开发者

Application_PreRequestHandlerExecute: null HttpContext.Current?

开发者 https://www.devze.com 2022-12-19 02:27 出处:网络
Is it safe to always assume that HttpContext.Current will 开发者_C百科be non-null in Application_PreRequestHandlerExecute?

Is it safe to always assume that HttpContext.Current will 开发者_C百科be non-null in Application_PreRequestHandlerExecute?

EDIT: Assuming ASP.NET webforms (not MVC).


Yes, unless you're running the code outside of the asp.net pipeline (in unit tests or some such).

The HttpApplication is handed an HttpContext upon creation.


There has to be a current httpcontext object if the app is running.

0

精彩评论

暂无评论...
验证码 换一张
取 消