Reputation: 175
How can we know which version of ASP.NET it is built in by looking into the ASP.NET project. Could somebody please list different ways to identify the version?
Thank you
Upvotes: 5
Views: 11781
Reputation: 49
I got this to work fine on ASP.NET v4.5, hope it helps. You may have to tweak it a bit for your system.
<%@ Page Language="VB" Debug="true" %>
<%
Dim cmnNETver, cmnNETsplt, dotNETver, dotNETsplt, aspNETver, aspNETsplt As Object
Dim osVersion, dotNETfil, aspNETfil, cmnNETfix, dotNETpth, dotNETtxt, dotNETfix, aspNETpth, aspNETtxt, aspNETfix As String
osVersion = System.Environment.OSVersion.ToString
dotNETfil = "ngen.exe"
aspNETfil = "clr.dll"
cmnNETver = System.Environment.Version.ToString
cmnNETsplt = cmnNETver.Split(".")
cmnNETfix = cmnNETsplt(0) & "." & cmnNETsplt(1) & "." & cmnNETsplt(2)
dotNETpth = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Windows) & "\Microsoft.NET\Framework64\v" & cmnNETfix & "\" & dotNETfil
If System.IO.File.Exists(dotNETpth) Then
dotNETver = System.Diagnostics.FileVersionInfo.GetVersionInfo(dotNETpth)
dotNETtxt = dotNETver.FileVersion.ToString
dotNETsplt = dotNETtxt.Split(" ")
dotNETfix = dotNETsplt(0) & " per " & dotNETfil
Else
dotNETfix = "Path not found... No version found..."
End If
aspNETpth = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Windows) & "\Microsoft.NET\Framework64\v" & cmnNETfix & "\" & aspNETfil
If System.IO.File.Exists(aspNETpth) Then
aspNETver = System.Diagnostics.FileVersionInfo.GetVersionInfo(aspNETpth)
aspNETtxt = aspNETver.FileVersion.ToString
aspNETsplt = aspNETtxt.Split(" ")
aspNETfix = aspNETsplt(0) & " per " & aspNETfil
Else
aspNETfix = "Path not found... No version found..."
End If
Response.Write("Common MS.NET version: " & cmnNETver & "<br>")
Response.Write("Common MS.NET path number: " & cmnNETfix & "<br>")
Response.Write("Microsoft.NET full path: " & dotNETpth & "<br>")
Response.Write("<b>Microsoft.NET version: " & dotNETfix & "</b><br>")
Response.Write("ASP.NET full path: " & aspNETpth & "<br>")
Response.Write("<b>ASP.NET version: " & aspNETfix & "</b><br>")
Response.Write("OS version: " & osVersion & "<br>")
%>
In the aspNETpath = "Framework64" can also be "Framework" worked either way for me, same output, output looks like this for me:
Common MS.NET version: 4.0.30319.42000
Common MS.NET path number: 4.0.30319
Microsoft.NET full path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe
Microsoft.NET version: 4.6.1586.0 per ngen.exe
ASP.NET full path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
ASP.NET version: 4.7.2110.0 per clr.dll
OS version: Microsoft Windows NT 10.0.14393.0
Cheers, AG
Upvotes: 1
Reputation: 6884
You need to be careful with the approach you use here because some updates to the .NET framework under ASP.NET will seemingly run under previous version numbers. For example;
There are a couple of ways to check the exact version you are running, on your web page add:
<%= System.Environment.Version.ToString() %>
As an example;
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\v4\Full
Within this location look at the Version node.
Upvotes: 7
Reputation:
Open the .csproj file and look inside of it. You'll see something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
...
</PropertyGroup>
</Project>
ProjectTypeGuids
is what identifies what kind of a Visual Studio project this thing is - an ASP.NET Application like in this example or some other type of a project. Different versions will also imply different GUIDs. You just have to find out what these IDs refer to.
Upvotes: 3