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.
我正在制作一个将从网页调用的方法,该方法使用Server.Transfer终止当前页面的执行并开始执行新页面。
但是,由于我正在制作的方法不是 aspx 页面,Service Studio 抱怨当前上下文中不存在服务器实例。
我该如何规避这个?
使用HttpContext.Current( System.Web.HttpContext class defined in System.Web)
HttpContext.Current
System.Web.HttpContext class defined in System.Web
即使您正在为 Web 应用程序开发类库,您也可以引用和使用它。
你会需要HttpContext.Current.Server,但你也可以在那里找到其他有用的数据。
HttpContext.Current.Server