Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
658 views
in Technique[技术] by (71.8m points)

asp.net - Get unique, static id from a device via web request

I have an MVC application that I would like to add some custom stats to. For some of the stats, it would be nice to have a unique identifier for a device.

For example, if I have a unique id for a RSS subscriber, I can monitor the active number of RSS subscribers.

I was wondering if anyone knew of anything in the web request that could be used as an ID other than the IP (which can obviously change). Something like a device ID or something?

Thanks,

Oliver

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here are some approaches to consider.

HTTP Headers

There are a few HTTP Headers you can look at that can help you identify a unique user or device - some would refer to the sim card, some refer to the device. Here is a list that I derived from the headers that Google Adsense Mobile uses to help track their advertising:

  • x-dcmguid
  • x-up-subno
  • x-jphone-uid
  • x-em-uid

These are probably some very popular one's, but there would be more vendor/device specific headers that are popular. You could start gathering all the headers your site receives and count how many of each you receive and start building up your own database of common headers.

Some other approaches

Cookies

Cookies is something that can be set on the requesting agent (browser for example) and returned when the agent visits again. For a list of methods, check out Ever Cookie - the virtually permanent cookie - it works by using one of the following methods of which at least one will work:

 - Standard HTTP Cookies 
 - Local Shared Objects (Flash Cookies)
 - Silverlight Isolated Storage 
 - Storing cookies in RGB values of auto-generated, force-cached 
    PNGs using HTML5 Canvas tag to read pixels (cookies) back out
 - Storing cookies in Web History 
 - Storing cookies in HTTP ETags 
 - Storing cookies in Web cache 
 - window.name caching
 - Internet Explorer userData storage
 - HTML5 Session Storage 
 - HTML5 Local Storage 
 - HTML5 Global Storage 
 - HTML5 Database Storage via SQLite

Combinations

It's also possible to come up with your own scheme, e.g. take the user-agent header, some other headers like accept, x-fowarded-for and the ip make a unique hash value of out them to more accurately determine the uniqueness of the agent.

There are many different mobile headers as seen here. I also hit a page of mine and store mobile headers from various devices for my own purposes here http://wap.defza.com/ua/ua.txt (also ua1.txt, ua2.txt etc)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...