Checking the Installed .NET Versions on Hosting Server

Introduction

Well, that very tiny post but it is very useful when you wish to know the exact what your hosting provider supports. No need to ask them (hosting company) that which extension you support. By using couples of lines code-behind you can do it yourself. Let's look at the code which will make it possible.

I am using a single .aspx page with VB code-behind.

Code

<%@ Page Language="VB" %>
<%
@ Import Namespace="Microsoft.Win32" %> 
<
script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim componentsKeyName As String = "SOFTWARE\Microsoft\NET Framework Setup\NDP"
        Dim componentsKey As RegistryKey = Registry.LocalMachine.OpenSubKey(componentsKeyName)
        Dim instComps As String() = componentsKey.GetSubKeyNames()
        For Each instComp As String In instComps
            Dim key As RegistryKey = componentsKey.OpenSubKey(instComp)
            If instComp IsNot Nothing AndAlso instComp.StartsWith("v") Then
                lblVersion.Text = lblVersion.Text & instComp & " SP " & key.GetValue("SP") & ", "
            End If
        Next
    End Sub
</
script>
<
html>
<
head id="Head1" runat="server">  
    
<title>CLR Versions</title>
</
head>
<
body>
    <form id="form1" runat="server">
        <asp:Label ID="lblVersion" runat="server">There is following versions installed and
running: </asp:Label>|
    </form>
</
body>
</
html>

HAVE A HAPPY CODING !!


Similar Articles