When I was first asked this question, I thought to look at the System.IntPtr struct. On further investigation, I found a very simple technique suggested by Perica Zivkovic.
Here’s how to determine if your ASP.NET application is running as a 32-bit or 64-bit application
C#
protected void Page_Load(object sender, EventArgs e)
{
if (IntPtr.Size == 8)
{
Response.Write("Running as a 64-bit app");
}
else if (IntPtr.Size == 4)
{
Response.Write("Running as a 32-bit app");
}
}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If IntPtr.Size = 8 Then
Response.Write("Running as a 64-bit app")
ElseIf IntPtr.Size = 4 Then
Response.Write("Running as a 32-bit app")
End If
End Sub
Note: There could be a possibility that you are running a 32-bit .NET Framework on a 64-Bit Windows OS. Check a cool technique described by Raymond How to detect programmatically whether you are running on 64-bit Windows
Tweet
1 comment:
great...
this is the easiest way to detect an environment.
Post a Comment