如何检查系统上加载的ASP.NET版本?

我如何检查我的系统上安装的ASP.NET版本?

您可以使用

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

这将得到当前运行的版本。 您可以在以下位置查看所有已安装版本的registry:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ NET Framework Setup \ NDP

当您使用Google Chrome +开发人员工具(预先安装)或Firefox + Firebug (加载项)加载页面时,可以看到执行哪个版本。

我使用Google Chrome:

  1. 打开Chrome并使用Ctrl + Shift + I打开开发人员工具。
  2. 转到“networking”选项卡
  3. 点击底部的“保留导航日志”button,
  4. 加载您的任何页面
  5. 点击回复标题

它看起来像这样:

在这里输入图像说明

看看c:\ windows \ Microsoft.NET \ Framework,你会看到各种以“v”开头的文件夹,表示安装的.NET版本。

我有同样的问题find一种方法来检查是否在服务器上的ASP.NET 4.5。 由于v4.5已经replace到v4.0,如果你看看c:\ windows \ Microsoft.NET \ Framework,你将不会看到v4.5文件夹。 其实有一个简单的方法来看到在机器上安装的版本。 在Windows Server 2008或Windows 7下,只需进入控制面板 – >程序和function,如果安装了“Microsoft .NET Framework 4.5”。

我正在寻找安装在我们服务器上的.net版本。 而这并不容易,而且由于就地升级了4. +版本,所以很容易被误导。 但是,我在MSDN上find了一个明确的答案。

这工作得很好。 重新安装后检查。

或者,您可以在网页和Page_Loadtypes中创build一个button;

 Trace.IsEnabled = True 

并在button点击事件types;

 Response.Write(Trace) 

这将调出所有的跟踪信息,您将在“X-ASPNet-Version”下的“Response Headers Collection”中find您的ASP.NET版本。

以下是一些将返回已安装的.NET详细信息的代码:

 <%@ 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>") %> 

这里是新的输出,更干净的代码,更多的输出:

 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