How can I check t开发者_运维知识库he version of ASP.NET
that is installed on my system?
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
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:
- Open Chrome and use Ctrl+Shift+I to open the developer tools.
- Go to the "Network" Tab
- Click on the small button at the bottom "Preserve log upon Navigation"
- Load any of your pages
- Click on the response header
It looks like this:
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.
Look in c:\windows\Microsoft.NET\Framework and you will see various folders starting with "v" indicating the versions of .NET installed.
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
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".
open a new command prompt and run the following command: dotnet --info
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.
精彩评论