In some client machines we are having some incompatibility issues related to the .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)
Console.WriteLine(Environment.Version.ToString());
Result:
4.0.30319.42000
2) Programatically reading:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
Result:
4.0.30319.0
3) Programatically reading:
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.
So, I have two questions:
1) How can I get the ASP.NET Version programmatically?
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). Is there a way to upgrade only 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:
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.