可以让网站刚运行时就加载。
1.添加Global.asax,在Application_Start函数中增加代码即可:
MyClass sp=new MyClass();
HttpContext.Current.Application["MyService"] = sp;
2.用到时使用MyClass m_sp = (MyClass)Application["MyService"];
Powered by: 博客园 Copyright © 2024 Zhiyett Powered by .NET 8.0 on Kubernetes