如何获取网站的ASP.NET版本 [英] How to get the ASP.NET version for the website
问题描述
我已经在.NET 2.0中开发了一个网站,并将其托管在loacl服务器上.
现在,我需要开发一个C#实用程序,以确保将该站点的ASP.NET版本设置为"2.0.50727".
我发现以下代码来检查站点的ASP.NET版本集.但这无法正常工作.这总是向我返回版本"2.0.50727",但是我在IIS中将站点版本设置为"1.1.4322"在我的网站的属性"->"ASP.NET"标签下.
Hi,
I have developed a website in .NET 2.0 and hosted it on the loacl server.
Now i need to develop a C# utility to ensure that the ASP.NET version for the site is set to "2.0.50727".
I have found following code to check the ASP.NET version set for the site.But this is not working .This always returns me the version as "2.0.50727" however i have set the site version as "1.1.4322" in IIS under Properties->ASP.NET tab for my site.
String sWebSite = "w3svc/1"
DirectoryEntry site = new DirectoryEntry("IIS://localhost/" + sWebSite + @"/Root");
PropertyValueCollection vals = site.Properties["ScriptMaps"];
foreach (string val in vals)
{
if (val.StartsWith(".aspx"))
{
string version = val.Substring(val.IndexOf("Framework") + 10, 9);
MessageBox.Show(String.Format("ASP.Net Version on virtual server is {0}", version));
}
}
链接: http://blogs.msdn.com/solutions/archive/2006/01/05/509844.aspx [ ^ ]
Link: http://blogs.msdn.com/solutions/archive/2006/01/05/509844.aspx[^]
推荐答案
检查以下链接,这可能对您有帮助
http://forums.iis.net/t/1148350.aspx [
Check the below link, this may help you
http://forums.iis.net/t/1148350.aspx[^]
这篇关于如何获取网站的ASP.NET版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!