通过查看ASP.NET项目,我们如何知道它所构建的ASP.NET版本。有人可以列出不同的方法来确定版本吗?
谢谢
答案 0 :(得分:4)
您需要小心使用此处使用的方法,因为ASP.NET下的.NET框架的某些更新似乎在以前的版本号下运行。例如;
有几种方法可以检查您运行的确切版本,在您的网页上添加:
<%= System.Environment.Version.ToString() %>
作为一个例子;
这将获得当前正在运行的版本。您可以在以下位置检查所有已安装版本的注册表:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ NET Framework Setup \ NDP \ v4 \ Full
在此位置查看版本节点。
答案 1 :(得分:2)
打开.csproj文件并查看其中。你会看到这样的事情:
<?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
标识了这个东西是什么类型的Visual Studio项目 - 像本示例中的ASP.NET应用程序或其他类型的项目。不同的版本也意味着不同的GUID。您只需要找出这些ID所指的内容。
答案 2 :(得分:1)
我在ASP.NET v4.5上运行得很好,希望它有所帮助。您可能需要为系统稍微调整一下。
<%@ 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>")
%>
在aspNETpath =“Framework64”中也可以“框架”为我工作,同样的输出,输出对我来说是这样的:
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
干杯,AG