iis ado.net version

1

Good,

I have the following code:

    private void AspNet35()
    {
        String sWebSite = "W3SVC/1";

        DirectoryEntry site = new DirectoryEntry("IIS://localhost/" + sWebSite + @"/Root");
        try
        {
            PropertyValueCollection vals = site.Properties["ScriptMaps"];
            foreach (string val in vals)
            {
                if (val.StartsWith(".aspx"))
                {
                    string version = val.Substring(val.IndexOf("Framework") + 10, 9);

                    if (version == "3.5") 
                    { 
                        MessageBox.Show(String.Format("ASP.Net Version on virtual server is {0}", version));
                    }
                }
            } 
        }
        catch
        {

        } 
    }

The idea was to check if IIS has ASP.NET 3.5 installed. Or at least check wanted the installed versions.

How can I do this?

Thank you

    
asked by anonymous 23.03.2016 / 10:16

1 answer

0

This Microsoft page contains several means of verifying the .Net Framework version:

How to Determine which .NET Framework versions are installed

For version 4.0 or later of the .Net Framework it suggests using Environment.Version, but previous versions do not have this property, so it suggests verifying the version using the Windows registry, except that the default Application user ASP.Net Pool does not have access to the registry, so it will be necessary to set up a different user in the ASP.Net App Pool on the web server for this to work.

    
23.03.2016 / 17:12