I would like to be able to check and see if a user is on windows regardless of version, can this be done using Razor with out having to look at each individual version? Was also interested in knowing if you can use Razor to detect which browser the user is on as well.
Asked
Active
Viewed 402 times
0
-
1You're looking for the [User agent of the browser](http://en.wikipedia.org/wiki/User_agent). – Lasse V. Karlsen Apr 09 '15 at 15:59
-
@LasseV.Karlsen I added some more context to the question, is it possible to detect if they are on any windows version? So that multiple if statements don't need to be made for each Windows version. – Stavros_S Apr 09 '15 at 16:23
-
1Yes, did you check the question I linked to? It is elementary code, in particular note that all the Windows versions in the answer to that question identifies themselves as different versions of "Windows NT". – Lasse V. Karlsen Apr 09 '15 at 16:39
-
Yes sorry, I was looking at the link from my phone and noticed some had NT while others didn't looking at it now on my monitor I see what you're saying. Thanks! – Stavros_S Apr 09 '15 at 17:28
1 Answers
2
You can use the Request.Browser and Request.UserAgent properties to get information about the client's platform and browser.
-
is it possible to check for all versions of windows in one if statement rather than having to look at each individual version? – Stavros_S Apr 09 '15 at 16:15
-
2you mean like this? `if (Request.UserAgent.IndexOf("Windows NT") > 0)` – Lasse V. Karlsen Apr 09 '15 at 16:40