Detects client monitor resolution, browser type, and client IP

Source: Internet
Author: User
Tags tostring win32 visual studio
Resolution | client | browser | The following code implements the ability to detect client display resolution, browser type, and client IP. You can save the client information to session,viewstate and so on to use it directly on other pages.

Clientpeek.aspx

<%@ Page language= "vb" Enableviewstate= "false" codebehind= "ClientPeek.aspx.vb"
Autoeventwireup= "false" inherits= "Aspxweb.clientpeek"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title> detects client display resolution, browser type, and client ip</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta content= "Microsoft Visual Studio 7.0" name= "Generator" >
<meta content= "C #" Name= "Code_language" >
<meta content= "" Mencius E Chapter ": http://xml.sz.luohuedu.net/" name= "CopyRight" >
<meta content= "JavaScript" name= "vs_defaultClientScript" >
<meta content= "http://schemas.microsoft.com/intellisense/ie5" name= "Vs_targetschema" >
</HEAD>
<body id= "Mybody" ms_positioning= "GridLayout" runat= "Server" >
<form id= "Browserpeek" runat= "Server" >
<asp:label id= "Label1" runat= "Server" ></asp:label></form>
</body>
</HTML>

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 generated by the Web Forms Designer

' This call is required by the Web Forms Designer.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()

End Sub

' NOTE: The following placeholder declarations are required by the Web Forms Designer.
' Do not delete or move it.
Private Designerplaceholderdeclaration as System.Object

Private Sub Page_Init (ByVal sender as System.Object, ByVal e as System.EventArgs) _
Handles Mybase.init
' CodeGen: This method call is required by the Web Forms Designer
' Do not modify it using the Code Editor.
InitializeComponent ()
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.Attributes.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 is:")
Strlabel.append (Request.Form ("Widthpixel"))
Strlabel.append ("x")
Strlabel.append (Request.Form ("Heightpixel"))
Strlabel.append ("Strlabel.append ("Browser basic information:<br>")
Strlabel.append ("Type =" & BC. Type & "<br>")
Strlabel.append ("Name =" & BC. Browser & "<br>")
Strlabel.append ("Version =" & BC.) Version & "<br>")
Strlabel.append ("Major Version =" & BC.) MajorVersion & "<br>")
Strlabel.append ("Minor Version =" & BC.) MinorVersion & "<br>")
Strlabel.append ("Platform =" & BC. Platform & "<br>")
Strlabel.append ("Is Beta =" & BC. Beta & "<br>")
Strlabel.append ("Is Crawler =" & BC. Crawler & "<br>")
Strlabel.append ("Is AOL =" & BC.) AOL & "<br>")
Strlabel.append ("Is Win16 =" & BC. Win16 & "<br>")
Strlabel.append ("Is Win32 =" & BC. Win32 & "<br>")
Strlabel.append ("Support Frames =" & BC.) Frames & "<br>")
Strlabel.append ("Support Tables =" & BC.) Tables & "<br>")
Strlabel.append ("Support Cookies =" & BC.) Cookies & "<br>")
Strlabel.append ("Support VB Script =" & BC.) VBScript & "<br>")
Strlabel.append ("Support JavaScript =" & BC.) JavaScript & "<br>")
Strlabel.append ("Support Java Applets =" & BC.) Javaapplets & "<br>")
Strlabel.append ("Support ActiveX Controls =" & BC.) ActiveXControls & "<br>")
Strlabel.append ("CDF =" & BC. CDF & "<br>")
Strlabel.append ("w3cdomversion =" + BC.) W3cdomversion.tostring + "<br>")
Strlabel.append ("useragent =" + request.useragent + "<br>")
Strlabel.append ("userlanguages =" + request.userlanguages (0). ToString + "<br>")
Strlabel.append ("Strlabel.append ("Client computer basic configuration:<br>")
Strlabel.append ("userhostname =" + Request.userhostname + "<br>")
Strlabel.append ("userhostaddress =" + request.userhostaddress + "<br>")
Label1.Text = strlabel.tostring ()
End If
End Sub

End Class


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.