Help on Server Variables....

Posted by Awaisdar001 under ASP.NET on 8/19/2011 | Points: 10 | Views : 1130 | Status : [Member] | Replies : 8
i need help on how to get server variables?
i want to get the client's operating system's name (i.e Windows XP, Windows 7, Windows Vista)
tell me how will i get this?




Responses

Posted by: Jpchoudhari on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
you can use HttpBrowserCapabilities to get this.
HttpBrowserCapabilities browser = Request.Browser;

Response.Write(browser.Platform);

you can find out more information it supports.

here is the list of server variables
http://www.codeproject.com/KB/asp/request_server_variables.aspx
you can use
Request.ServerVariables["REMOTE_HOST"].ToString();



Kind Regards,
Jay

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

in addittion to above answer..
To get server variableshttp://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables.aspx
u can also use below code to get operating system's name.
Request.UserAgent


Thanks & Regards,

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Awaisdar001 on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
<Request.UserAgent> is returning the following data.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9

i need to get "WINDOWS XP"
like facebook is storing the user;s logs.

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
@Awaisdar001,
Ur right ..
have a look at this below link..
http://dnohr.dk/aspnet/how-to-detect-browser-operating-system-os-with-aspnet
Update :
You can check if the OS version number is in the User agent. If you're looking in the example I did post above this text, you can see a Windows NT number, that's the number who indicate the specific Windows version. "Windows NT 5.1" means that this user is using Windows XP. To read complete article Click above link



Thanks & Regards,

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

what does this code giving... for me its giving correct version of OS

HttpBrowserCapabilities browser = Request.Browser;

Response.Write(browser.Platform);


Kind Regards,
Jay

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
@Jpchoudhari
The code linr u mentioned gives WinNT as result when i tested , but em usin win 7...

Thanks & Regards,

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Awaisdar001 on: 8/19/2011 [Member] Starter | Points: 25

Up
0
Down
so i am still looking for that answer :(

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/20/2011 [Member] Starter | Points: 25

Up
0
Down
@Awaisdar001,

<Request.UserAgent> is returning the following data.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9

i need to get "WINDOWS XP"
Ok look, the above output u got is having browser and OS details like OS version number here in ur case Windows NT 5.1 it means Windows XP OS and Windows 6.1 means Windows 7 or Windows Server 2008 R2

I hope now ur more clear on this..

Thanks & Regards,

Awaisdar001, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response