Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
始终假设 HttpContext.Current 在 Application_PreRequestHandlerExecute 中不为空是否安全?
编辑:假设 ASP.NET 网络表单(不是 MVC)。
是的,除非您在 asp.net 管道之外运行代码(在单元测试等中)。
它HttpApplication是一HttpContext经创造的。
HttpApplication
HttpContext
如果应用程序正在运行,则必须有一个当前的 httpcontext 对象。