[英]Getting ASP.NET Version programmatically
In some client machines we are having some incompatibility issues related to the .NET Framework. 在某些客户端计算机中,我们遇到了一些与.NET Framework相关的不兼容问题。
When a server error is encountered, an error page is displayed. 遇到服务器错误时,将显示错误页面。 On the bottom of the page we have this information:
在页面底部,我们具有以下信息:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1637.0
I´ve read different posts and tried multiple things in order to get that value programmatically without success. 我读过不同的文章,并尝试了多种方法,以便以编程方式获得成功的价值。
This is what I´ve tried: 这是我尝试过的:
1) 1)
Console.WriteLine(Environment.Version.ToString());
Result: 结果:
4.0.30319.42000
2) Programatically reading: 2)以编程方式阅读:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
Result: 结果:
4.0.30319.0
3) Programatically reading: 3)以编程方式阅读:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
Result: 结果:
4.6.01586
As you can confirm none of those values map the ASP.NET Version showed in the error page. 您可以确认这些值均未映射错误页面中显示的ASP.NET版本。
So, I have two questions: 因此,我有两个问题:
1) How can I get the ASP.NET Version programmatically? 1)如何以编程方式获取ASP.NET版本?
2) I faced a case where .NET4.6 was apparently installed but ASP.NET Version was 4.0.30319 (and the suspicion is that this is causing the failure). 2)我遇到的一个情况是显然安装了.NET4.6,但是ASP.NET版本是4.0.30319(并且怀疑这是导致失败的原因)。 Is there a way to upgrade only ASP.NET?
有没有办法只升级ASP.NET? Makes this any sense?
这有意义吗?
I apologize I don´t have enough reputation to add images. 抱歉,我没有足够的声誉来添加图像。
I am able to answer to your first question. 我可以回答你的第一个问题。
You can receive ASP.NET version programmatically like that: 您可以像这样以编程方式接收ASP.NET版本:
var netPath =
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
var systemWebPath = Path.Combine(netPath, "System.Web.dll");
if (File.Exists(systemWebPath))
{
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(systemWebPath);
string version = fileVersionInfo.ProductVersion;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.