IIS 5 & IIS 6
Odd IIS Session Problem . . . asp pages fail to load 1st time . .. bu...
Last post Jan 29, 2009 01:17 PM by mmurphy384
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
Jan 29, 2009 07:24 AM|tomkmvp|LINK
Please share the full error message and some code ...
Jan 29, 2009 07:33 AM|mmurphy384|LINK
The error message is:
The offending code takes a delimited SessionData string and gets a name/value pair out of it:
' 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))
last = InStr(first+1,SessionData,chr(254))
Result = Mid(SessionData,first, last-first)
GetSessionVar = Result
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.
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.
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?
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=DT_STARTTIME VALUE=1/29/2009 9:47:15 AMþ>
<NAME=DT_LASTACCESS VALUE=1/29/2009 9:49:15 AMþ>
<NAME=VAR_USERAGENT VALUE=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:18.104.22.168) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4þ>
<NAME=VAR_GMTOFFSET VALUE=-0500 ESTþ>
When I run it through the function, I see results such as:
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.
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.
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:
' basically, the oSessionData.find returns something that looks like "INT_USERID=12345"
' and I just grab what's right of the "="
Thanks again for your time. If I ever truly figure it out, I'll post it here.
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)
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.
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))
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.