我在我的Asp.Net应用程序中使用了 `System.Timers.Timer`,并且需要使用 `HttpServerUtility.MapPath` 方法,但似乎只能通过 `HttpContext.Current.Server.MapPath` 访问。问题是当 `Timer.Elapsed` 事件触发时,`HttpContext.Current` 是 `null`。
是否有另一种方法来获取 `HttpServerUtility` 对象的引用? 我可以在我的类构造函数中注入它。这样做安全吗?如何确保它不会在当前请求结束时被垃圾回收?
谢谢!
是否有另一种方法来获取 `HttpServerUtility` 对象的引用? 我可以在我的类构造函数中注入它。这样做安全吗?如何确保它不会在当前请求结束时被垃圾回收?
谢谢!