Reputation: 669
I am using asp.net core 2.0.
In c# code on server side I want to check the IIS version where the website is hosted.
Earlier in asp.net the following line gives us the iis version.
HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"];
It was giving me the result like Microsoft-IIS/10.0
How to get the desired result in asp.net core ?
Upvotes: 3
Views: 2070
Reputation: 25380
Updated my code to asp.net core 2.2, still not able to get the value of this variable
If you're using asp.net core 2.2 or above, get the IServerVariablesFeature
as below:
var serverVars = HttpContext.Features.Get<IServerVariablesFeature>();
var iisVersion = serverVars == null ? null : serverVars["SERVER_SOFTWARE"];
Upvotes: 5