ASP.NET中全局变量

1.同一页面: ViewState;
2.不同页面:Session;
3.application
    如:
 1 // 在Web.Config中
 2 < configuratin >
 3    < appSettings >
 4      < add key = " dsn "  value = " sdfjklsfldf " />
 5    </ appSettings >
 6 </ configuration >
 7
 8 // xx.ASPx.cs
 9 using  System.Configuration;
10
11 protected   string  str  =  ConfigurationSettings.AppSettings[ " dsn " ];
4.在Globle.asax 中定义
     //全局变量
      public static string greeting = "China is good!";

你可能感兴趣的:(asp.net)