简体   繁体   English

在C#中的静态函数中访问服务器变量时出现问题

[英]Problem accessing Server variable in static function in C#

Im unable to access server/response variable in my static function. 我无法在我的静态函数中访问服务器/响应变量。 Can i access them in static function or should i include some namespaces 我可以通过静态函数访问它们还是应该包含一些命名空间?

I'm having a really hard time understanding your question, but is it possible that you are looking for HttpContext.Current ? 我很难理解您的问题,但是您可能正在寻找HttpContext.Current吗?

var context = HttpContext.Current;
// now you can use context.Request, context.Response, context.Server, etc.

System.Web.HttpContext.Current对象包括当前ServerResponseRequest等实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM