ASP. NET obtains client information

Source: Internet
Author: User
Tags servervariables

Using system. Collections. Specialized

Int loop1, loop2;
Namevaluecollection Coll;
 
// Load servervariable collection into namevaluecollection object.
Coll = request. servervariables;
// Get names of all keys into a string array.
String [] arr1 = Coll. allkeys;
For (loop1 = 0; loop1 <arr1.length; loop1 ++)
{
Response. Write ("key:" + arr1 [loop1] + "<br> ");
String [] arr2 = Coll. getvalues (arr1 [loop1]);
For (loop2 = 0; loop2 <arr2.length; loop2 ++)
{
Response. Write ("value" + loop2 + ":" + arr2 [loop2] + "<br> ");
}
}

 

 

==== The following is an example of obtaining IP addresses, operating systems, and browsers ========

Private string getip ()
{/* Obtain the real IP address of the remote user through the proxy server :*/
If (request. servervariables ["http_via"]! = NULL)
Return request. servervariables ["http_x_forwarded_for"]. tostring ();
Else
Return request. servervariables ["remote_addr"]. tostring ();
}
Label2.text = getip ();
Httpbrowsercapabilities BC = new httpbrowsercapabilities ();
BC = request. browser;
String Xitong = "your operating system is ";
Label3.text = Xitong + bc. Platform + "browser type:" + bc. type;

 

Related Article

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.