如何查看系统上安装的ASP.NET
版本?
答案 0 :(得分:35)
您可以使用
<%
Response.Write("Version: " + System.Environment.Version.ToString());
%>
这将获得当前正在运行的版本。您可以在以下位置检查所有已安装版本的注册表:
HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ NET 框架设置\ NDP
答案 1 :(得分:34)
使用Google Chrome +开发人员工具(预装)或Firefox + Firebug(附加组件)加载页面时,您可以查看执行的版本。
我使用谷歌浏览器:
看起来像这样:
答案 2 :(得分:4)
查看c:\ windows \ Microsoft.NET \ Framework,您将看到以“v”开头的各种文件夹,表示已安装.NET的版本。
答案 3 :(得分:4)
我遇到同样的问题,想办法检查ASP.NET 4.5是否在服务器上。因为v4.5到位取代v4.0,如果你看c:\ windows \ Microsoft.NET \ Framework,你将看不到v4.5文件夹。实际上有一种简单的方法可以查看机器中安装的版本。在Windows Server 2008或Windows 7下,只需转到控制面板 - &gt;程序和功能,如果安装了“Microsoft .NET Framework 4.5”,您将找到它。
答案 4 :(得分:2)
或者,您可以在网页和Page_Load类型中创建一个按钮;
Trace.IsEnabled = True
在按钮点击事件类型中;
Response.Write(Trace)
这将显示所有跟踪信息,您将在&#34;响应标头集合&#34;中找到您的ASP.NET版本。在&#34; X-ASPNet-Version&#34;。
答案 5 :(得分:2)
以下是一些将返回已安装的.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
答案 6 :(得分:0)
打开一个新的命令提示符并运行以下命令: dotnet --info
答案 7 :(得分:0)
我也需要此信息,并通过此方法获得了信息,
启动PowerShell
运行“导入模块服务器管理器”命令(不带引号)
之后对asp.net 3.5进行检查 运行“ get-windowsfeature web-asp-net”命令(不带引号)
用于asp.net 4.5检查 运行“ get-windowsfeature Net-Framework-45-Core”命令(不带引号)
这两个命令都将在“安装状态”标题下通知您。
在服务器环境中通过GUI检测版本,有关详细信息,请参见in this link.