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

Reading number is top 10 articles
asp.net2.0内置Application对象的应用
Visual,Studio,2008,Professional,简体中文RTM版,体验(1)_[Asp.Net教程]
asp.net2.0访问母版页的控件和属性
asp.net定制简单的错误处理页面_[Asp.Net教程]
GridView,批量删除,自定义分页,定位页码_[Asp.Net教程]
网站繁简转换解决方案--ASP,JSP,PHP,.Net通用_php资料_编程技术
客户端回调实现gridView无刷新分页_.net资料_编程技术
MSSQL数据库嵌套存储过程的事务控制_mssql学习_编程技术
学习动态网页技术PHP中错误处理的一些方法_php资料_编程技术
C#教程:建立动态链接库
Reading number is top 10 pictures
男人,就要活出棱角
Sora aoi possession photo1
Men's and women's orgasms
奇趣的世界记录1
男人帮杂志里的惹火性感美女2
张家界的玻璃桥
看到这名字我也是醉了。。。。。。
5 meters long centenarians python and melee was successfully capture king snake (figure)
大年初五接财神
NeedWallpaper3
Download software ranking
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
双旗镇刀客A
WebService在.NET中的实战应用教学视频 → 第2集
Tram sex maniac 2 (H) rar bag13
Unix video tutorial8
Boxer vs Yellow4
1400篇各类破解文章
网络管理员第三版
WebService在.NET中的实战应用教学视频 → 第3集
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
qq published in(发表于) 2014/7/9 1:39:27 Edit(编辑)
asp.net中Server对象的应用实例

asp.net中Server对象的应用实例

asp.net中Server对象的应用实例

Server对象的应用

本节通过一个简单的实例来介绍如何使用Server对象来获得客户端和服务器的相关信息。实例运行结果如图1所示。



图1 Server对象的应用

程序开发步骤如下。

(1)新建一个网站,命名为15_05,其主页默认为Default.aspx。

(2)在Default.aspx页面中添加一个Table表格,用来布局页面,然后在该Table表格中添加5个Label控件,分别用来显示客户端和服务器端的相关信息。

(3)程序主要代码如下。

Default.aspx页面的Page_Load事件中,分别调用Server对象和Request对象的相关属性获取客户端和服务器端信息,并将这些信息显示在相应的Label控件中。Default.aspx页面的Page_Load事件代码如下:

protected void Page_Load(object sender, EventArgs e)

{

Label2.Text = Request.Browser.Platform;

Label3.Text = Request.Browser.Type;

Label5.Text = Server.MachineName.ToLower();

Label1.Text = Request.UserHostAddress;

string hostName = Dns.GetHostName();

IPAddress[] hostip;

hostip = Dns.GetHostAddresses(hostName);

foreach (IPAddress ip in hostip)

{

Label4.Text = ip.ToString();

}

}

完整程序代码如下:

★ ★★★★Default.aspx页面设计文件完整程序代码★★★★★

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







无标题页















客户端/服务器端信息












&nbsp;&nbsp;

服务器端信息:








&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IP地址:


&nbsp; &nbsp; 计算机名称:






&nbsp;&nbsp;

客户端信息:








&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IP地址:


&nbsp; &nbsp; &nbsp; &nbsp; 操作平台:


&nbsp; &nbsp; 浏览器版本:




















★ ★★★★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;

using System.Net;

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



添加到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.