我在 Gloabal.asax.cs 中声明了一个静态字符串“drivePath”。在 webrole 的 Onstart 事件中,我为其分配了一个值。我正在我的网页上访问此值,但它显示为好像刚刚声明了该变量。我为我的代码得到的值如下
全球.asax.cs
public static string drivePath = string.Empty;
WebRole.cs
public override bool OnStart()
{
MountAzureDrive();
Global.drivePath = WebRole.drivePath;
return base.OnStart();
}
我在“MountAzureDrive()”函数中为 WebRole.drivePath 赋值。
在网页上
在某些功能的网页上,我将 drivePath 作为“Global.drivePath”访问,并且我将值作为 string.Empty。
我的问题是为什么不保留驱动路径的值?如果我想保留 drivepath 的价值并得到它,我该怎么办?
请帮我
提前致谢。