All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP实例:一个非常全面获取图象信息的PHP函数_php资料_编程技术
教你IIS6的PHP最佳配置方法_[PHP教程]
Silverlight,2(beta1)数据操作(3)—使用ADO.NET,Data,Service_[Asp.Net教程]
关于ASP.NET,2.0的目录结构变化_[Asp.Net教程]
C#中定义鼠标指针为指定的图片实例
Windows,Server,2003,安全配置实战演习_[SQL,Server教程]
从数据库导出数据到word、excel、.txt_.net资料_编程技术
C#中continue语句的使用方法
Asp.net实例:实现图片上传_[Asp.Net教程]
《Effective,C#》-使用成员初始化语句_[Asp.Net教程]
Reading number is top 10 pictures
A man's favorite things4
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line1
再发两张抽象画
YangYuYing and ZhengShaoQiu dance on the generous come interest dye-in-the-wood
Summer is most suitable for young people to travel in China6
你白吃了多少药
邪恶搞笑内涵图
运动的范冰冰1
XuRe xuan cool and refreshing photoes1
Discharge accidentally Actresses by the breast2
Download software ranking
美女写真3
Be there or be square
仙剑奇侠传98硬盘WINXP版
Boxer vs Yellow4
Photoshop 8.0图象编辑软件
Take off clothes to survival
DreamWeaver8
Unix video tutorial9
The king of fighters 97(Mobile phone games-apk)
豪门浪荡史
qq published in(发表于) 2014/7/9 1:36:56 Edit(编辑)
asp.net2.0内置Request对象的属性

asp.net2.0内置Request对象的属性

asp.net2.0内置Request对象的属性

Request对象的属性

Request对象常用属性及说明如表1所示。





表1 Request对象常用属性及说明

下面对比较重要的属性进行详细介绍。

(1)Browser属性。用于获取或设置有关正在请求的客户端浏览器的信息。

* 示例

使用Browser属性获得浏览器信息

本示例实现的是,当程序运行时,在页面Default.aspx中输出浏览器的一些相关信息。示例运行结果如图1所示。



图1 使用Browser属性获得浏览器信息

程序代码如下。

在Default.aspx页面的Page_Load事件中,调用Request对象的Browser属性输出与浏览器相关的一些信息,实现代码如下:

protected void Page_Load(object sender, EventArgs e)

{

Response.Write("浏览器使用的平台:" + Request.Browser.Platform + "
" + "浏览器类型:" + Request. Browser.Type + "
" + "浏览器版本:" + Request.Browser.Version);

}

完整程序代码如下:

★ ★★★★Default.aspx代码文件完整程序代码★★★★★

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>







无标题页

















★ ★★★★Default.aspx.cs代码文件完整程序代码★★★★★

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

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

{

protected void Page_Load(object sender, EventArgs e)

{

Response.Write("浏览器使用的平台:" + Request.Browser.Platform + "
" + "浏览器类型:"

+ Request.Browser.Type + "
" + "浏览器版本:" + Request.Browser.Version);

}

}

(2)QueryString属性。用于获取HTTP查询字符串变量的集合。

* 示例

使用QueryString属性实现地址栏传值

本示例实现的是,当程序运行时,在页面Default.aspx中的TextBox文本框中输入一个值,然后单击【传值】按钮,将TextBox文本框中的值传到Default2.aspx页面的地址栏中。示例运行结果如图2和图3所示。



图2 Default.aspx页面



图3 Default2.aspx页面

程序代码如下。

Default.aspx页面中,单击【传值】按钮,程序跳转到Default2.aspx页面,并使用标识ID将TextBox文本框中的值传到Default2.aspx页面中。【传值】按钮的Click事件代码如下:

protected void Button1_Click(object sender, EventArgs e)

{

Response.Redirect("Default2.aspx?id=" + TextBox1.Text);

}

Default2.aspx页面中,使用Request对象的QueryString属性接收Default.aspx页面中的值,实现代码如下:

protected void Page_Load(object sender, EventArgs e)

{

Response.Write("地址栏传值id为:" + Request.QueryString["id"]);

}

(3)UserHostAddress属性。用于获取远程客户端的主机IP地址。例如,用一个字符串来记录远程客户端的主机IP地址,代码如下:



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.