63

How can I check the version of ASP.NET that is installed on my system?

royhowie
  • 11,075
  • 14
  • 50
  • 67
vanaja
  • 631
  • 1
  • 5
  • 4
  • 3
    Programmatically or just what you have in your windows install? – Jimmy May 11 '11 at 18:48
  • 2
    I believe this may be a duplicate of http://stackoverflow.com/questions/5161529/how-to-know-which-version-of-asp-net-it-is – aceinthehole May 11 '11 at 18:52
  • 2
    @aceinthehole No, that question is about which version a project was coded against. This is about which version is installed on the machine. – Ryan Shillington Jan 20 '16 at 18:20
  • half of the answers below are about seeing which version of .net you are running. The other half are about the machine. I for one need to see the .net version i'm coding against be because i wan't to check something in asp.net source code. – eran otzap Sep 23 '16 at 19:49

8 Answers8

45

You can use

<%
Response.Write("Version: " + System.Environment.Version.ToString());
%>

That will get the currently running version. You can check the registry for all installed versions at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
keyboardP
  • 68,824
  • 13
  • 156
  • 205
  • Great. Thank You very much guys for such a quick response. Stack Over flow Rocks. – vanaja May 11 '11 at 19:28
  • But one question to Keyboardp. Where should i run the command you sent <% Response.Write........%> – vanaja May 11 '11 at 19:29
  • 1
    You can create a new ASPX page and copy/paste that into your page. If you want to do it from the code-behind, then just use ` Response.Write("Version: " + System.Environment.Version.ToString() );` without the `<% %>` – keyboardP May 11 '11 at 19:32
  • 4
    This answer is the best way to check as both the "on page" script and the registry check will show v4.0 vs v4.5 differerences. If you have version 4.5 installed a Response.Write on the page will display either v4.0.30319.34209 (instead of v4.0.30319.1008) and in the registry, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full you'll see the version v4.5.51209 (instead of v4.0.30319) – Mark Cooper Feb 25 '15 at 07:49
  • Make sure that you add this an aspx file and not a asp file or else it will not work – Coded Container Mar 15 '18 at 15:14
42

You can see which version gets executed when you load the page with Google Chrome + developer tools (preinstalled) or Firefox + Firebug (add-on).

I use Google Chrome:

  1. Open Chrome and use Ctrl+Shift+I to open the developer tools.
  2. Go to the "Network" Tab
  3. Click on the small button at the bottom "Preserve log upon Navigation"
  4. Load any of your pages
  5. Click on the response header

It looks like this:

enter image description here

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • 8
    This doesn't show the differences between v4.0 and v4.5 as both run under the same X-AspNet-Version of 4.0.30319. You need to check the registry or do a Response.Write as answered by @KeyboardP. – Mark Cooper Feb 25 '15 at 07:51
  • 4
    This method permets to find out the `.NET CLR Framework` version, not the `ASP.NET` version ... – serge Jan 19 '16 at 13:56
  • You can hide the "X-Asp-Net-Version" header quite easy as written [here](http://www.admin-enclave.com/en/articles/windows/285-windows-hardening-disable-the-x-aspnet-version-header.html) so this solution will not always work. – BastianW Sep 28 '16 at 19:59
6

I had same problem to find a way to check whether ASP.NET 4.5 is on the Server. Because v4.5 is in place replace to v4.0, if you look at c:\windows\Microsoft.NET\Framework, you will not see v4.5 folder. Actually there is a simple way to see the version installed in the machine. Under Windows Server 2008 or Windows 7, just go to control panel -> Programs and Features, you will find "Microsoft .NET Framework 4.5" if it is installed.

Xudong Jin
  • 99
  • 1
  • 2
4

Look in c:\windows\Microsoft.NET\Framework and you will see various folders starting with "v" indicating the versions of .NET installed.

schummbo
  • 890
  • 4
  • 14
  • 6
    I installed version 4.5 and that version does NOT show up under the Framework directory. So your solution isn't correct. – Johann Apr 18 '13 at 17:30
  • 1
    If it exists, did you check c:\windows\Microsoft.NET\FFramework64 – Rich Jan 30 '14 at 18:49
3

Here is some code that will return the installed .NET details:

<%@ Page Language="VB" Debug="true" %>
<%@ Import namespace="System" %>
<%@ Import namespace="System.IO" %>
<% 
Dim cmnNETver, cmnNETdiv, aspNETver, aspNETdiv As Object
Dim winOSver, cmnNETfix, aspNETfil(2), aspNETtxt(2), aspNETpth(2), aspNETfix(2) As String

winOSver = Environment.OSVersion.ToString
cmnNETver = Environment.Version.ToString
cmnNETdiv = cmnNETver.Split(".")
cmnNETfix = "v" & cmnNETdiv(0) & "." & cmnNETdiv(1) & "." & cmnNETdiv(2)

For filndx As Integer = 0 To 2
  aspNETfil(0) = "ngen.exe"
  aspNETfil(1) = "clr.dll"
  aspNETfil(2) = "KernelBase.dll"

  If filndx = 2   
    aspNETpth(filndx) = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), aspNETfil(filndx))
  Else
    aspNETpth(filndx) = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Microsoft.NET\Framework64", cmnNETfix, aspNETfil(filndx))
  End If

  If File.Exists(aspNETpth(filndx)) Then
    aspNETver = Diagnostics.FileVersionInfo.GetVersionInfo(aspNETpth(filndx))
    aspNETtxt(filndx) = aspNETver.FileVersion.ToString
    aspNETdiv = aspNETtxt(filndx).Split(" ")
    aspNETfix(filndx) = aspNETdiv(0)
  Else
    aspNETfix(filndx) = "Path not found... No version found..."
  End If
Next

Response.Write("Common MS.NET Version (raw): " & cmnNETver & "<br>")
Response.Write("Common MS.NET path: " & cmnNETfix & "<br>")
Response.Write("Microsoft.NET full path: " & aspNETpth(0) & "<br>")
Response.Write("Microsoft.NET Version (raw): " & aspNETtxt(0) & "<br>")
Response.Write("<b>Microsoft.NET Version: " & aspNETfix(0) & "</b><br>")
Response.Write("ASP.NET full path: " & aspNETpth(1) & "<br>")
Response.Write("ASP.NET Version (raw): " & aspNETtxt(1) & "<br>")
Response.Write("<b>ASP.NET Version: " & aspNETfix(1) & "</b><br>")
Response.Write("OS Version (system): " & winOSver & "<br>")
Response.Write("OS Version full path: " & aspNETpth(2) & "<br>")
Response.Write("OS Version (raw): " & aspNETtxt(2) & "<br>")
Response.Write("<b>OS Version: " & aspNETfix(2) & "</b><br>")
%>

Here is the new output, cleaner code, more output:

Common MS.NET Version (raw): 4.0.30319.42000
Common MS.NET path: v4.0.30319
Microsoft.NET full path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe
Microsoft.NET Version (raw): 4.6.1586.0 built by: NETFXREL2
Microsoft.NET Version: 4.6.1586.0
ASP.NET full path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
ASP.NET Version (raw): 4.7.2110.0 built by: NET47REL1LAST
ASP.NET Version: 4.7.2110.0
OS Version (system): Microsoft Windows NT 10.0.14393.0
OS Version full path: C:\Windows\system32\KernelBase.dll
OS Version (raw): 10.0.14393.1715 (rs1_release_inmarket.170906-1810)
OS Version: 10.0.14393.1715
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
2

Alternatively, you can create a button on your webpage and in the Page_Load type;

Trace.IsEnabled = True

And in the button click event type;

Response.Write(Trace)

This will bring up all the trace information and you will find your ASP.NET version in the "Response Headers Collection" under "X-ASPNet-Version".

JPM
  • 189
  • 1
  • 3
  • 14
  • You can hide the "X-Asp-Net-Version" header quite easy as written [here](http://www.admin-enclave.com/en/articles/windows/285-windows-hardening-disable-the-x-aspnet-version-header.html) so this solution will not always work. – BastianW Sep 28 '16 at 20:01
2

open a new command prompt and run the following command: dotnet --info

MMSabbagh
  • 21
  • 5
1

I needed this information too and got information with this method,

Launch PowerShell

run the 'import-module servermanager' command ( without quotes )

after that for asp.net 3.5 check run the 'get-windowsfeature web-asp-net' command ( without quotes )

for asp.net 4.5 check run the 'get-windowsfeature Net-Framework-45-Core' command ( without quotes )

Both of the commands will inform you below Install State header.

Detecting version via GUI in server environment and details can be found in this link.

Hamit Enes
  • 122
  • 1
  • 5