Sample Function for VaryByCustom

Note: Use this code to over-ride GetVaryByCustomString with a custom function in the global.asax file for your application. For this to work you should add the following function to your global.asax file:

<script language="VB" runat="server">

Public Overrides Function GetVaryByCustomString(context As HttpContext, arg As String) As String
  If (arg = "clientlevel") Then
    Dim iEcmaVersion As Decimal = 0
    Dim iDomVersion As Decimal = 0
    Dim iMajorVersion As Integer = 0

    Try
      iEcmaVersion = Request.Browser("EcmaScriptVersion")
      iDomVersion = Request.Browser("MSDomVersion")
      iMajorVersion = Request.Browser("MajorVersion")
    Catch
      Return "downlevel"
    End Try

    If iEcmaVersion >= 1.2 And iDomVersion >= 4 And iMajorVersion >= 4 Then
      Return "uplevel"
    Else
      Return "downlevel"
    End If
  End If
End Function

</script>