2008/07/29

C#中关于Request的练习

using System;

using System.Configuration;

using System.Data;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;


public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

//获取相对路径

Response.Write(Request.ServerVariables["url"]);

Response.Write("<br>"+Request.RawUrl);


//获取绝对路径

Response.Write("<br>"+Request.ServerVariables["path_translated"]);

Response.Write("<br>"+Request.PhysicalPath);


//获取服务器名

Response.Write("<br>"+Request.ServerVariables["server_name"]);


//获取服务器IP

Response.Write("<br>"+Request.UserHostAddress);


//客户端浏览器是否支持背景音乐

Response.Write("<br>"+Request.Browser.BackgroundSounds);


//客户端浏览器是否支持框架

Response.Write("<br>"+Request.Browser.Frames);


//客户端的操作系统类型

Response.Write("<br>"+Request.Browser.Platform);

}

}


输出结果:

/RequestTest/Default.aspx

/RequestTes/Default.aspx

H:\网站\天轰穿\111\Default.aspx

H:\网站\天轰穿\111\Default.aspx

localhost

127.0.0.1

True

True

WinXP

没有评论: