怎么给asp.net创建全局变量?
在global.asax中建立的其他文件取不出来,是我搞错了吗?
public static String aStr;
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
EntryFilePath = Server.MapPath( "abc ");
}
比如default.aspx.cs和App_Code/class.cs中就取不到aStr的值
哪里错了吗?
该如何建立全局变量?
------解决方案--------------------void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application[ "EntryFilePath "] = Server.MapPath( "abc ");
}
------解决方案--------------------可以在Application_Start中使用Application变量:
string astr = "abc ";
Application[ "ASTR "] = astr;
-------------------------------------------
在default.aspx.cs种如下方法取出:
string bstr = Application[ "ASTR "].ToString();
//对Application变量取出事要做类型转换