The following code implements the ability to detect the resolution of the client display, the browser type, and client IP. You can save client information into session, viewstate, etc. to use them directly on other pages.
Clientpeek.aspx
! <% @ Page language = "vb" EnableViewState = "false" Codebehind = "ClientPeek.aspx.vb" AutoEventWireup = "false" Inherits = "aspxWeb.ClientPeek"%>
Clientpeek.aspx.vb
Imports system
Public Class ClientPeek Inherits System.Web.UI.Page Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents MyBody As System.Web.UI.HtmlControls.HtmlGenericControl
#Region "The code" of the web form designer "
'This call is required for the web form designer.
'Note: The following placeholders declare are required by the web form designer. 'Don't delete or move it. Private DesignerPlaceHolderDeclaration as System.Object
Private sub page_init (Byval e as system.Event, byval e as system.eventargs _ handles mybase.init 'Codegen: This method call is required by the Web Form Designer' Do not modify it using the code editor. InitializationComponent () End Sub
#End region
Private Sub Page_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load Dim Button1 As New System.Web.UI.WebControls.Button If Not Me.IsPostBack Then Dim btnW As New System.Web. UI.HtmlControls.HtmlInputHidden Dim btnH As New System.Web.UI.HtmlControls.HtmlInputHidden Button1.ID = "Button1" btnW.Name = "WidthPixel" btnW.ID = "WidthPixel" btnH.Name = "HeightPixel" btnH.ID = "HeightPixel" Me.FindControl ( "browserpeek"). Controls.Add (btnW) Me.FindControl ( "browserpeek"). Controls.Add (btnH) Me.FindControl ( "browserpeek"). Controls.Add (Button1) Dim scriptString As String = "" scriptString = "document.browserpeek.WidthPixel.value = window.screen.width;" scriptString = "document.browserpeek.HeightPixel.value = window.screen.height;" Me.RegisterOnSubmitStatement ( "Meng" , scriptstring) me.mybody.attributes.add ("OnLoad", "Document.browserpeek.Button1.click ();") else me.mybody.attribu tes.Remove ( "onload") If Me.FindControl ( "browserpeek"). Controls.Contains (Button1) Then Me.FindControl ( "browserpeek"). Controls.Remove (Button1) Button1.Dispose () End If Dim strLabel As New System.Text.StringBuilder Dim bc as HttpBrowserCapabilities = Request.Browser strLabel.Append ( "your browser's resolution:") strLabel.Append (Request.Form ( "WidthPixel")) strLabel.Append ( "×" Strlabel.Append (Request.form ("Heightpixel")) Strlabel.Append ("