CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2001
    Posts
    2,529

    Classic ASP <object> and Windows Versions / Request.Servervariables("HTTP_USER_AGENT"

    I am updateing an ASP Classic website. ASP is definitely not my forte, but I have done a little.

    I am trying to load objects one way for Windows 7+ and another way for Windows XP.
    I use the CODEBASE for Windows XP, and not for Windows 7. Regardless of OS, the
    first method appears to be used by the browser.

    #1 Why is this?
    #2 Is there a case where the browser downloads the control from the server if the CODEBASE tag is left off?

    My understanding is that if you use the CODEBASE tag, then the browser checks the control version and if an old
    version exists on the Client, downloads it from the server.


    Code:
    Dim strAgentA
    Dim aryAgentElemsA, strOSA
    
    strAgentA = Request.Servervariables("HTTP_USER_AGENT")
    aryAgentElemsA = Split(strAgentA, ";")
    strOSA = aryAgentElemsA(2)
    
    If strcomp(trim(strOSA),"Windows NT 6.1") = 0 Then
    %>
    <object ID="oPersonalInbox"> 
    CLASSID="CLSID:0006F063-0000-0000-C000-000000000046" 
    HEIGHT="100%"
    WIDTH="100%">
    <param NAME="View" VALUE="">
    <param NAME="Folder" VALUE="Inbox">
    <param NAME="Namespace" VALUE="MAPI">
    <param NAME="Restriction" VALUE="">
    <param NAME="DeferUpdate" VALUE="0">
    </object>
    
    <%
    else
    %>
    <object ID="oPersonalInbox"> 
    CLASSID="CLSID:0006F063-0000-0000-C000-000000000046" 
    CODEBASE="outlctlx.CAB#ver=9,0,0,3203"
    HEIGHT="100%"
    WIDTH="100%">
    <param NAME="View" VALUE="">
    <param NAME="Folder" VALUE="Inbox">
    <param NAME="Namespace" VALUE="MAPI">
    <param NAME="Restriction" VALUE="">
    <param NAME="DeferUpdate" VALUE="0">
    </object>
    <%
    end if
    ahoodin
    To keep the plot moving, that's why.

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Classic ASP <object> and Windows Versions / Request.Servervariables("HTTP_USER_AG

    hello anybody out there?
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: Classic ASP <object> and Windows Versions / Request.Servervariables("HTTP_USER_AG

    Sorry, these forums are very little traffic now-a-days. I personally check in about once a week now.

    If only the first <object> is initializing regardless of OS, then the strcomp(trim(strOSA),"Windows NT 6.1") is always returning 0.

    What exactly does strAgentA = Request.Servervariables("HTTP_USER_AGENT") return?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Classic ASP <object> and Windows Versions / Request.Servervariables("HTTP_USER_AG

    No worries PeeJavery, I am just happy to have a response, Thanks mate. Thanks very much!

    Request.Servervariables("HTTP_USER_AGENT") returns a string with semi-colon delimited text as such:
    XP Box:
    Code:
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 1.1.4322)
    Windows 7 Box:
    Code:
      
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
    The following code displays "Windows 7" if viewed by a browser on a Windows 7 Client,
    otherwise "Unknown".

    Code:
    	Dim strAgent
    	strAgent = Request.Servervariables("HTTP_USER_AGENT")
    	Dim aryAgentElems, strOS, strOK
    	strOK = "False"
    	aryAgentElems = Split(strAgent, ";")
    	strOS = aryAgentElems(2)
            If strcomp(trim(strOS),"Windows NT 6.1") = 0 Then
              Response.Write("Windows 7")
            else 
              Response.Write("Unknown")
            End if
    As you can see split converts the string into an array using the semicolon to parse out "tokens" or fields.

    If I plug the code with the <object> tag, it should work the same way, but it doesn't
    appear to. Why is that?

    That is my question.

    I appreciate the help!
    Last edited by ahoodin; February 20th, 2013 at 01:01 PM.
    ahoodin
    To keep the plot moving, that's why.

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: Classic ASP <object> and Windows Versions / Request.Servervariables("HTTP_USER_AG

    Rather than splitting up the string, have you tried just doing a string search?

    Code:
    <% If InStr(strAgent, "Windows NT 6") Then %>
    ...
    <% Else %>
    ...
    <% End If %>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured