Using C# Code Behind
You can use the following code to find out if the incoming request is from any Mobile device or not (the following code is not updated for Android but you can easily build on it).
string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") ||
strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") ||
strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") ||
strUserAgent.Contains("palm"))
{
//Request from Mobile Device
}
else{
//Request from Computer
}
}
Once, request is identified to be orignated from any computer, you can put the following code to detect its operating system.
if (Request.UserAgent.IndexOf("Windows NT 5.1") > 0)
{ //Windows XP
}
else if (Request.UserAgent.IndexOf("Windows NT 5.0") > 0)
{ //Windows 2000
}
else
{ //Other Operation System
}
Using .aspx Page
Paste this in an .aspx page no code behind needed.
<!-- p class="title">Browser Capabilities :</p -->
<table width="90%" border="0" align="center"
cellpadding="2" cellspacing="2">
<tr class="header">
<td width="30%">Property</td>
<td>Value</td>
</tr>
<tr>
<td>ActiveXControls </td>
<td> <%= Request.Browser.ActiveXControls %></td>
</tr>
<tr>
<td>AOL </td>
<td> <%= Request.Browser.AOL %></td>
</tr>
<tr>
<td>BackgroundSounds </td>
<td> <%= Request.Browser.BackgroundSounds %></td>
</tr>
<tr>
<td>Beta </td>
<td> <%= Request.Browser.Beta %></td>
</tr>
<tr>
<td>Browser </td>
<td> <%= Request.Browser.Browser %></td>
</tr>
<tr>
<td>CDF </td>
<td> <%= Request.Browser.CDF %></td>
</tr>
<tr>
<td>ClrVersion </td>
<td> <%= Request.Browser.ClrVersion %></td>
</tr>
<tr>
<td>Cookies </td>
<td> <%= Request.Browser.Cookies %></td>
</tr>
<tr>
<td>Crawler </td>
<td> <%= Request.Browser.Crawler %></td>
</tr>
<tr>
<td>EcmaScriptVersion </td>
<td> <%= Request.Browser.EcmaScriptVersion %></td>
</tr>
<tr>
<td>Frames </td>
<td> <%= Request.Browser.Frames %></td>
</tr>
<tr>
<td>JavaApplets </td>
<td> <%= Request.Browser.JavaApplets %></td>
</tr>
<tr>
<td>JavaScript </td>
<td> <%= Request.Browser.JavaScript %></td>
</tr>
<tr>
<td>MajorVersion </td>
<td> <%= Request.Browser.MajorVersion %></td>
</tr>
<tr>
<td>MinorVersion </td>
<td> <%= Request.Browser.MinorVersion %></td>
</tr>
<tr>
<td>MSDomVersion </td>
<td> <%= Request.Browser.MSDomVersion %></td>
</tr>
<tr>
<td>Platform </td>
<td> <%= Request.Browser.Platform %></td>
</tr>
<tr>
<td>Tables </td>
<td> <%= Request.Browser.Tables %></td>
</tr>
<tr>
<td>Type </td>
<td> <%= Request.Browser.Type %></td>
</tr>
<tr>
<td>VBScript </td>
<td> <%= Request.Browser.VBScript %></td>
</tr>
<tr>
<td>Version </td>
<td> <%= Request.Browser.Version %></td>
</tr>
<tr>
<td>W3CDomVersion </td>
<td> <%= Request.Browser.W3CDomVersion %></td>
</tr>
<tr>
<td>Win16 </td>
<td> <%= Request.Browser.Win16 %></td>
</tr>
<tr>
<td>Win32 </td>
<td> <%= Request.Browser.Win32 %></td>
</tr>
</table>
No comments:
Post a Comment