如何在ASP.Net中取得环境变量的值
点击次数:19 次 发布日期:2008-11-27 00:07:22 作者:源代码网
|
源代码网推荐 源代码网推荐 导 读:服务器端的变量在编程中有很重要,下面的代码将显示出所有的服务器端变量。 源代码网推荐 -------------------------------------------------------------------------------- 源代码网推荐 飞刀 源代码网推荐 aspcn.com 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 这个小程序中,我会教大家如何在ASP.Net中取得环境变量。程序的示例在 源代码网推荐 源代码网推荐 http://aspx1.brinkster.com/feidao/code/Server.aspx 源代码网推荐 源代码网推荐 下面是源程序: 源代码网推荐 源代码网推荐 <% @ Page Language="C#" %> 源代码网推荐 <% @ Import Namespace="System.Data" %> 源代码网推荐 <script Language="C#" Runat="Server"> 源代码网推荐 public void Page_Load(Object src,EventArgs e) 源代码网推荐 { 源代码网推荐 //本程序用来取得所有环境变量的值 源代码网推荐 } 源代码网推荐 </script> 源代码网推荐 <html> 源代码网推荐 <head> 源代码网推荐 <title></title> 源代码网推荐 </head> 源代码网推荐 <body> 源代码网推荐 下面是获得的环境变量列表(Show All Value Of ServerVariables): 源代码网推荐 源代码网推荐 <p> 源代码网推荐 <table border=1> 源代码网推荐 <tr><td>环境变量名(ServerVariable)</td><td>其值(Value)</td></tr> 源代码网推荐 <% 源代码网推荐 源代码网推荐 NameValueCollection rsv=Request.ServerVariables; 源代码网推荐 //获得环境变量的个数 源代码网推荐 int rsvCount=rsv.Count; 源代码网推荐 //用于取得Key值 源代码网推荐 string strKey; 源代码网推荐 源代码网推荐 for(int i=0;i<rsvCount;i++) 源代码网推荐 { 源代码网推荐 strKey=rsv.GetKey(i); 源代码网推荐 %> 源代码网推荐 <tr> 源代码网推荐 <td><% =strKey %></td> 源代码网推荐 <td><% =rsv.Get(strKey) %></td> 源代码网推荐 </tr> 源代码网推荐 <% } %> 源代码网推荐 </table> 源代码网推荐 </p> 源代码网推荐 看看所有的环境变量都出来了 源代码网推荐 </body> 源代码网推荐 </html> 源代码网推荐 源代码网推荐 源代码网推荐 源代码网供稿. |
