In order to make my web application responsive I am using Request.Browser.IsMobileDevice
to detect if the request is coming from a mobile device and if so either making specific changes in the page so that it be suitable for mobile devices or redirecting to another page. This has to be done a number of times. For use on one page I'm putting the information in a hidden field that way it can be accessed both on server and client side. In moving from one page to another where I must detect again whether the device is mobile, what's more efficient, using Request.Browser.IsMobileDevice
each time or saving the information in a Session
variable and accessing the information from there?
Asked
Active
Viewed 544 times
1

Dov Miller
- 1,958
- 5
- 34
- 46
1 Answers
3
Request.Browser.IsMobileDevice
is a property whose value is judged by the request context (e.g. user-agent info in the HTTP header). The framework will build the context, no matter you use it or not. Meanwhile the judgement's cost is quite low. Then why not just use the built-in function? Storing it in the session makes everything more complex.

Cheng Chen
- 42,509
- 16
- 113
- 174