Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh [Answered]RSS

9 replies

Last post Jan 29, 2009 01:17 PM by mmurphy384

  • Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 28, 2009 05:15 PM|mmurphy384|LINK

    My development machine has been working great for months (new in Nov) and just recently started exhibiting the following:

     

    1) The first time I attempt to load any .asp page in the site, it returns a vbruntime error.  I don't think it matters, but it fails on a simple INSTR() function call to read data in a session cookie.  I've verified that everything in that INSTR function call is legitimate.  It's like IIS/asp loses it's mind.

    2) If I refresh the page, it works just fine.

    3) If I EDIT that page and save it . . . . . I get a repeat of steps 1 + 2.

    I don't use session state in my application, so I turned that completely off (thinking the session cookie was causing problems).  That only makes the problem worse in that the page never actually loads . .. .this is why I think it is related to session state. 

     I've done everything.  Uninstalled Anti-virus, uninstalled backup agents, unintalled desktop search/indexing agents, etc., etc,. etc.

    Any suggestions would be greatly appreciated. 

     

    IIS ASP Session Refresh

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 07:24 AM|tomkmvp|LINK

    Please share the full error message and some code ...

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 07:33 AM|mmurphy384|LINK

    The error message is:

  • Error Type:
    Microsoft VBScript runtime (0x800A0005)
    Invalid procedure call or argument: 'Mid'
    /include/header.asp, line 3560

     

  • Browser Type:
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

    The offending code takes a delimited SessionData string and gets a name/value pair out of it:

    Function GetSessionVar(FieldName)

        Dim Result

        Dim p, first, last

        If Len(Trim(FieldName)) > 0 Then

            ' If Fieldname is found - p will have the position in SessionData

            ' SessionData is a delimited string of

              name/value pairs: <NAME=int_UserID VALUE=12345%><NAME=var_OrgName 

              value=ACME Something%> . . . (pretend the % is chr(254))

            p = InStr(SessionData,UCase(FieldName))

     

            If (p > 0) Then

                first = InStr(p,SessionData,"=") + 1

                last = InStr(first+1,SessionData,chr(254))

                Result = Mid(SessionData,first, last-first)

            Else

                Result = "NOT FOUND"

            End If

        End If

        If (Err.number <> 0) then

            Result = ""

            Err.Clear

        End If

        GetSessionVar = Result

    End Function

     

     The underlying problem is that the function thinks that the SessionData is NULL in some cases (though, it's not . . I've even hard-coded the SessionData string and it still fails).

     Thanks for taking a peek.

     

     

     

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 07:36 AM|mmurphy384|LINK

    one more reminder .. . . bear in mind that a refresh "fixes" the problem . . .that's why I don't really think it's a code problem.

     Also, when I disable the SessionState option in IIS, the problem occurs relentlessly.  Refresh does not work when in this configuration. 

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 08:44 AM|tomkmvp|LINK

    I suspect something is wrong with the data for:

    first = InStr(p,SessionData,"=") + 1
    last = InStr(first+1,SessionData,chr(254))

    Can you add some debug code to write out what those two functions produce?

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 10:00 AM|mmurphy384|LINK

    This really isn't a code problem as the same code works fine on other servers.

    Here's what happens when someone loads any page on the site.

    We deposit a session cookie with a GUID and start a session.

    We call a COM+ VB application to read in the sessionData based on the GUID.

    Here's where I think the problem is.  Even though in debug mode, I see this string being created in the COM+ app, it isn't being returned to the calling asp page (not when SessionState is disabled).  Our application doesn't use IIS Sessions, so we like to leave those disabled).  If I enable SessionState, it works on a 2nd refresh only (and any subsequent visit to that page).

     So . .. .when we call GetSessionData, the vbApp returns:

     SessionData = <NAME=INT_SESSIONSACTIVEID VALUE=20792688þ>
    <NAME=GUID VALUE={2B704CFA-611A-4506-BF8D-305D20F3C8F1}þ>
    <NAME=INT_USERID VALUE=0þ>
    <NAME=DT_STARTTIME VALUE=1/29/2009 9:47:15 AMþ>
    <NAME=DT_LASTACCESS VALUE=1/29/2009 9:49:15 AMþ>
    <NAME=INT_PAGECOUNT VALUE=8þ>
    <NAME=INT_DISTRICTID VALUE=0þ>
    <NAME=INT_SUBJECTID VALUE=0þ>
    <NAME=VAR_DISTRICTSTATE VALUE=0þ>
    <NAME=VAR_DISTRICTNAME VALUE=0þ>
    <NAME=VAR_FIRSTNAME VALUE=0þ>
    <NAME=VAR_LASTNAME VALUE=0þ>
    <NAME=VAR_EMAIL VALUE=0þ>
    <NAME=VAR_GRADE VALUE=0þ>
    <NAME=BIT_ISDISTRICTADMIN VALUE=Falseþ>
    <NAME=BIT_ISDISTRICTCONFIG VALUE=Falseþ>
    <NAME=BIT_ISINSTRUCTOR VALUE=Falseþ>
    <NAME=BIT_ISCATALOGADMIN VALUE=Falseþ>
    <NAME=BIT_ISACCOUNTINGADMIN VALUE=Falseþ>
    <NAME=BIT_ISCUSTOMERSERVICE VALUE=Falseþ>
    <NAME=BIT_ISSYSADMIN VALUE=Falseþ>
    <NAME=BIT_ISINSTRUCTIONAL VALUE=0þ>
    <NAME=VAR_USERAGENT VALUE=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4þ>
    <NAME=VAR_HOST VALUE=127.0.0.1þ>
    <NAME=VAR_SELECTEDTAB VALUE=Loginþ>
    <NAME=BIT_ISMLP VALUE=Falseþ>
    <NAME=INT_WEBREGID VALUE=0þ>
    <NAME=BIT_CHANGEPASSWORD VALUE=Trueþ>
    <NAME=BIT_CHANGEUSERNAME VALUE=Trueþ>
    <NAME=BIT_ISPROGRAMADMIN VALUE=Falseþ>
    <NAME=VAR_WEBREGDISTRICTNAME VALUE=0þ>
    <NAME=VAR_WEBREGLOGOFILE VALUE=0þ>
    <NAME=VAR_WEBREGRETURNURL VALUE=0þ>
    <NAME=VAR_WEBREGHEADERCOLOR VALUE=0þ>
    <NAME=VAR_WEBREGLEFTNAVCOLOR VALUE=0þ>
    <NAME=BIT_WEBREGISREGCUSTOMER VALUE=Falseþ>
    <NAME=BIT_WEBREGUSEHEADER VALUE=Falseþ>
    <NAME=BIT_ISEMAILCUSTOMER VALUE=Falseþ>
    <NAME=VAR_GMTOFFSET VALUE=-0500 ESTþ>
    <NAME=BIT_ISWEBHOSTCUSTOMER VALUE=Falseþ>
    <NAME=BIT_USEWORKFLOW VALUE=Trueþ>
    <NAME=BIT_WEBREGMULTI VALUE=Falseþ>
    <NAME=BIT_ISBETAUSER VALUE=Falseþ>
    <NAME=INT_SESSIONTIMEOUTMIN VALUE=5þ>
    <NAME=BIT_ISFILEUPLOADCUSTOMER VALUE=Falseþ>
    <NAME=BIT_ISFILEUPLOADUSERS VALUE=Falseþ>
    <NAME=BIT_ISCALENDARCUSTOMER VALUE=Falseþ>
    <NAME=BIT_ISCALENDARUSER VALUE=Falseþ>
    <NAME=BIT_CONFPROPOSALSUBMITTED VALUE=Falseþ>
    <NAME=BIT_CONFREGISTRATIONCOMPLETED VALUE=Falseþ>
    <NAME=BIT_VOTED VALUE=Falseþ>
    <NAME=TXT_PREFS VALUE=0þ>
    <NAME=VAR_RIGHTS VALUE=0þ>
    <NAME=VAR_ABSENCEPROVIDERNAME VALUE=0þ>

    When I run it through the function, I see results such as: 

    FieldName First Last segment of SessionData
    int_UserID 124 142 INT_USERID VALUE=0þ>
    int_DistrictID 278 815 INT_DISTRICTID VALUE=0þ>
    int_SubjectID 307 321 INT_SUBJECTID VALUE=0þ>
    var_DistrictState 340 815 VAR_DISTRICTSTATE VALUE=0þ>
    var_DistrictName 372 830 VAR_DISTRICTNAME VALUE=0þ>
    bit_IsInstructional 783 830 BIT_ISINSTRUCTIONAL VALUE=0þ>
    var_AbsenceProviderName 2096 0 VAR_ABSENCEPROVIDERNAME VALUE=0þ>
    var_FirstName 401 410 VAR_FIRSTNAME VALUE=0þ>
     

    Note that the "LAST" column often misses the chr(254) and grabs one later in the string or none at all.

     Again . . . I don't think this is a code problem so much as it is a IIS/COM+ configuration problem.

     I'm stumped, that's for sure.

     Thanks for taking a peek.

     

    Mike

     

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 10:11 AM|mmurphy384|LINK

    I appreciate your help on this, but please don't spend too much time.  I'm down to taking pot shots at this point and fear my mis-diagnosis at each step is going to confuse things more and more.

    I was hoping to learn that there was a recent update patch that causes wierd IIS/COM+ interractions in classic asp.

    I've done a full virus scan.  Perhaps I'll reinstall IIS and re-create my com+ apps.

     Thanks again.

    Mike

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 11:48 AM|mmurphy384|LINK

    I'm embarrassed to admit defeat, but instead fixing the problem, I now use a better means of extracting the name/value pair (one that doesn't rely on INSTR).

    Basically, we use a string component that does a nice job of handling a delimited list and extracting name/value pairs.  For the sake of giving "props", its the Dart component made by PowerTCP.

    function getSessionVar now looks like:

    Function GetSessionVar(FieldName)

     

         Dim Result

     

         Result = ""

         ' basically, the oSessionData.find returns something that looks like "INT_USERID=12345"

         ' and I just grab what's right of the "="

     

         Result = Right(oSessionData.Find(FieldName),
    Len(oSessionData.Find(FieldName))-                                   (len(FieldName)+1))

     

        GetSessionVar=Result

    End Function

     

     Thanks again for your time.  If I ever truly figure it out, I'll post it here.

     

     

     

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 12:58 PM|mmurphy384|LINK

    Ok .. .perhaps I have a little more pride than I thought.

    There seems to be a problem with the chr() set on my computer.

     I changed the following line and it all works:

            last = InStr(first+1,SessionData,(chr(254))

            last = InStr(first+1,SessionData,"þ")

     As for why this is occuring on the intial load of any .asp page . . .  . . . for that, I will gladly admit defeat.  I just don't care anymore.

     Thanks again.

     

    Mike

     

     

     

     

  • Re: Odd IIS Session Problem . . . asp pages fail to load 1st time . .. but ok on refresh

    Jan 29, 2009 01:17 PM|mmurphy384|LINK

    Fortunately, I work with people that take a lot of pride in what they do.

     

    It appears that chr(254) has some odd behaviors related to Microsoft's ANSI and everyone else's characters set.

     If I use ChrW instead of Chr, it works just fine too.  Chr(254) resolves to "th" on my computer, so that's what it would pick up.

    last = InStr(first+1,SessionData,(chrW(254))

    http://www.eggheadcafe.com/forumarchives/NETVisualBasic/Jun2005/post23575952.asp 

    It appears I can adjust the setting in Windows - Control Panel - Regaion/Language so that it uses the "western European" set.

    I am D-U-N.  Sorry for taking up IIS time on this.

     

    Mike

  • ‹ Previous Thread|Next Thread ›