ado.net version of iis

Asked

Viewed 55 times

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 it?

Thank you

  • You didn’t ask any questions

  • The question was how do I know if Asp.net 3.5 is installed using c#? tried with the above code but it didn’t work.

  • I have withdrawn -1 now that the question is clear

1 answer

0

This Microsoft page contains several ways to check the . Net Framework version:

How to determine which. NET Framework versions are installed

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.