What is all the browser agent stuff?

2019-03-01 19:28发布

问题:

I am new to ASP.NET and wanted to capture details about people on my site. So I capture the Request.UserAgent attributes to file. Can anyone explain how to deconstruct these so I know what they mean? I am actually stumped by some of the user agents I see. Examples:

  • IE2.0d; WinNT: Mozilla/1.22 (compatible; MSIE 2.0d; Windows NT): Never heard of IE2.0, so is this spoofed for scanning my site, and why? Also, how is IE related to Mozilla in this case?
  • IE6.0; WinXP: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; YPC 3.0.2; .NET CLR 1.1.4322; yplus 4.4.02b): People seriously use IE6.0 these days?? And what is all the rest of that stuff, like YPC and yplus?
  • Mozilla0.0; Win2000: Mozilla/4.76 [en] (Windows NT 5.0; U): Hmmm... That's a weird Mozilla version?

回答1:

I think this website will be very helpful to you: http://www.useragentstring.com/pages/useragentstring.php

You can copy and paste user agents into this index page and have it do a simple analysis. http://www.useragentstring.com/index.php



回答2:

A user agent is used to identify the application that accessed a specific web site or service.

The common pattern:

Mozilla/[version] ([system and browser information]) [platform] ([platform details]) [extensions]

Source for this information: Wikipedia

Since the user agent is exposed by a commonly accessible string, this can be modified easily (aka spoofed) - a method that can be easily done in .NET by directly modifying the UserAgent property - that way you can, for example, identify your download manager as Internet Explorer while it doesn't have anything to do with it. Not saying it's a good practice since it messes with visit stats, but you need this from time to time - for example, to access a web stream from a website that is only accessible through an app and not through a web browser. All you need is to know the user agent for that app and then pass it inside your own application.

A pretty decent source of information for your case would be MSDN. In case you are wondering why IE is sometimes identified as Mozilla, here is what Microsoft has to say in their official docs:

For historical reasons, Internet Explorer identifies itself as a Mozilla 4.0 browser.