More playing with ASP.NET

As with my earlier messing around with a poll, I took a concept from the site today and made my own "CheckDotNet.aspx" page. The one on only checks for the .NET Framework 1.0 or better, so I modified the logic to detect 1.1 and 1.0 as two distinct cases... recommending an upgrade for no framework or 1.0, and returning "Framework Found" if you have 1.1 already.

Difficult? Nope... nothing too impressive...

Useful? I have no idea, but I thought it was worth putting up. The page has only one bit of code, the load event handler (and yes, I know I could have overriden OnLoad... but the code I started with was using Page_Load, so I just went with it)...

     Sub Page_Load(sender as Object, e as EventArgs)
        Dim clrVersion as Version = Request.Browser.ClrVersion
If clrVersion.Major > 0 Then
         If clrVersion.Minor > 0 Then
             aOkPanel11.Visible = True
             aOkPanel1.Visible = True
         End If
            downloadPanel.Visible = True
        End If
    End Sub

aOkPanel11 on my page contains the text to show if the user has the 1.1 version of the Framework... aOkPanel1 is shown if they have 1.0 only, and downloadPanel appears if they have no Framework at all.

Ouch... I guess I was porting/modifying that code way too quickly... goofed up the logic in a bunch of ways (thanks for the comments folks!)... at the risk of trying again and still screwing it up... here is another try at that routine;

    Sub Page_Load(sender as Object, e as EventArgs)
Dim clrVersion as Version = Request.Browser.ClrVersion
if clrVersion.Major = 1 Then
if clrVersion.Minor > = 1 Then
'1.1 or better, but less than 2.0
             aOkPanel11.Visible = true
ElseIf clrVersion.Minor = 0 Then
'only 1.0
             aOkPanel1.Visible = true
end if
elseif clrVersion.Major > 1 Then
'2.x or greater... could have its own panel
            'but showing the 1.1 panel is probably the next
            'best thing...
            aOkPanel11.Visible = true
'anything else... should display for
            '< 1.0 or nothing...
            downloadPanel.Visible = true
end if
end sub
Also, in the html of the aOkPanel11, which can appear for the .NET Framework 1.1 or greater... I changed the text to reflect this possibility and added


hopefully, this 'release' works better than the last one 🙂


Comments (5)

  1. Jerry Pisk says:

    You can just load the page in any browser other than IE, then it won’t detect anything (unless you go into the pains and modify their user-Agent strings to include the .Net CLR version).

  2. BillT says:

    It will also report 1.1 if any higher version is installed on the machine. The code should be written to antipate future versions.

  3. Jens Peter Karlsen says:

    I know that there is no version over 1.1 but you should still add logic to check for this as there no doubt will be a higher version available. Probably when Whidbey ships or sooner.

    Regards Jens Peter Karlsen. Microsoft MVP – Frontpage.

  4. Jerry Pisk says:

    Bill, it will actually report 1.0 if 2.0 (or any X.0) is installed. It’s not a very good check.

  5. Jerry Pisk says:

    How about:

    Dim clrVersion as Version = Request.Browser.ClrVersion

    if clrVersion.Major < 1 Then

    ‘< 1.0 or nothing…

    downloadPanel.Visible = true

    ElseIf clrVersion.Major = 1 And clrVersion.Minor < 1 Then

    ‘ 1.0

    aOkPanel1.Visible = true

    ElseIf clrVersion.Major = 1

    ‘ 1.x

    aOkPanel11.Visible = true


    ‘ 2+

    aOkPanel11.Visible = true


    Seems a little cleaner and easier to understand than your nested ifs version, especially when it’s in VB (too many keywords expressin structure).

Skip to main content