相关疑难解决方法(0)

在静态类中访问HttpContext.Current

我可以HttpContext.Current在静态类和方法中调用吗?

我想在每个用户的基础上存储一个值,但希望能够以静态方式访问它.

这会有用吗?

public static class StaticClass
{

    public static string SomeThing
    {
        get { return HttpContext.Current.Items["SomeItem"].ToString(); }
    }

}
Run Code Online (Sandbox Code Playgroud)

c# asp.net static

13
推荐指数
3
解决办法
9446
查看次数

标签 统计

asp.net ×1

c# ×1

static ×1