Checking the Installed .NET Versions on Hosting Server


Introduction

Well, this is 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 ObjectByVal e AsSystem.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 AndAlsoinstComp.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>

Comments

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples