0

I have created a function in c# which uses the user agent and returns the OS and its architecture. It works fine except for the Firefox 3.6.28 where it shows the 32bit windows XP instead of 64bit XP

user agent-string returned by FF 3.6.28

"Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28 GTB7.1 ( .NET CLR 3.5.30729) "

here is the code

HttpBrowserCapabilities browser = Request.Browser;
    string platform = browser.Platform;
    Response.Write(platform +"</br>");

     if (platform.Contains("Win"))
     {
        Response.Write("Your OS : Windows </br>");
        string str = Request.UserAgent;
        if (str.IndexOf("WOW64") != -1 ||   str.IndexOf("Win64") != -1)
        {
            Response.Write("This is a 64 bit OS </br></br>");

        }
        else
        {
            Response.Write("Not a 64 bit OS");
        }
        Response.Write(str + "</br></br>");

     }
     else
     {
         Response.Write("Your OS :Non  Windows </br>");

     }
user987166
  • 69
  • 3
  • Clearly there is no token in that u/a string sent by the browser that identifies its host os's bitness ... what solution do you expect their to be? – Alex K. Mar 19 '12 at 11:12
  • I don't get the problem. The string does not contain any of the expected patterns so x32 is the correct answer ? – Steve Mar 19 '12 at 11:13
  • question is : how can i get OS architecture if the user agent doesnt send "WOW64 , X64 or WIN64" in user agent string – user987166 Mar 19 '12 at 11:13
  • yah but wat about if a browser is running on 64 bit OS and its doesnt send any pattern to be identified as 64 bit OS – user987166 Mar 19 '12 at 11:15
  • You can't from the User-Agent - best bet is jscript: this previous question may help: http://stackoverflow.com/questions/1741933/detect-64-bit-or-32-bit-windows-from-user-agent-or-javascript – ianbailey Mar 19 '12 at 11:28
  • You seem to be detecting whether or not the 64 bit OS is running a 32 bit version of the application. If the OS is 32 bit, the function will return that the OS is not 64 bit, if the OS is 64 bit and the application is 64 bit, the function will return that the OS is not 64 bit, the function will only return that the OS is 64 bit if the 64 bit OS is running a 32 bit application. – JMK Mar 19 '12 at 12:18

0 Answers0