enableSessionState - still struggling

M

Martin

Hi,

I had a page the other day for which the compiler just wouldn't recognize
the fact that I had enabled session state in every possible way. I ended up
moving the code that dealt with the Session object from code-behind to
in-page and it worked. Didn't find an explanation though but it got me up
again.

Today it got worse. Now what sense does this make:

<%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
<%
Session.Abandon
%>

Above is the entire aspx-page (saved with an aspx extansion). Can't get much
simpler than this, right? It gives me the horrifying "Session state can only
be used when enableSessionState is set to true, either in a configuration
file or in the Page directive".

Both machine.config and my application's web.config file have
enableSessionState set to "true", which should be the default anyway. I am
using this version:

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

Please help me.

Martin.
 
H

Hermit Dave

Martin i atually havent the slightest clue as to y its happening but why do
you have
<%@Page Language="VBScript"
there is not VBScript in aspx any more...
<%@Page Language="VB"

and just use web.config file in the app dir for your application based
session state config
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong
to a particular session.
If cookies are not available, a session can be tracked by adding a
session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

hope this helps,

HD
 
A

Alvin Bruney

i've copied and pasted your simple page into a new project. i don't get that
error. can you give more informatiton on this? It seems to be specific to a
setting on your computer and not to the framework or the environment
otherwise i would be getting it as well. Makes sense?
 
M

Martin

there is not VBScript in aspx any more...

Oh, well... Remnants of the pre-.NET era. I changed it to VB. Usually the
compiler gives me "xxx no longer supported but in this case it didn't mind.
and just use web.config file in the app dir for your application based
session state config
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong
to a particular session.
If cookies are not available, a session can be tracked by adding a
session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

This section wasn't in web.config, the default in machine.config should
apply. I added it in web.config and tried it cookieless. No difference. I
believe this section primarily enables you to use centralized out-of-server
state management. Default on-server state management is okay for me.
hope this helps,

Apart from making me feel a little better knowing there's folk out there
thinking with me, not really yet. :)
 
M

Martin

i've copied and pasted your simple page into a new project. i don't get
that error.

That is good to know, thank you.
can you give more informatiton on this? It seems to be specific to a
setting on your computer and not to the framework or the environment
otherwise i would be getting it as well. Makes sense?

About a week ago another guy posted the same problem. Neither of us had
found anything on the matter so it does make sense to assume it is some
local problem. I have it on both my machines though, a Windows Server 2003
and a Windows XP Professional system (to which I copied the lot just to see
the response).

Another page in the same application does allow me to address the session
object. Do I however put the line that increments a session variable all the
way up, making it the first statement in the page, then it fails again (the
succeeding line is in a post-back section further down).

Still flabbergastered.

Martin.
 
A

Alvin Bruney

You might want to open up a trouble ticket with microsoft so they can take a
memory dump of your system to see what's wrong.

Either you use this option or it's trial and error which burns a lot of
time. I'm running xp pro with frame 1.1 and it works smoothely here. The
link to microsoft provides you with 3, free trouble tickets to use anyway
you please. After they are used up, your are charged per ticket so use
wisely.

Here is a link:
http://support.microsoft.com/default.aspx?scid=fh;[ln];oasoem
 
M

Martin

Hi,

Fixed it. When I renamed web.config I had my session again. Further
investigation brought it down to this:

<configuration>
<system.web>
<httpModules>
<!-- <add name="Session"
type="System.Web.SessionState.SessionStateModule"/> -->
</httpModules>
</system.web>
</configuration>

There are other entries for OutputCache and WindowsAuthentication left out
for brevity). For some reason the session module declaration was commented
out. I can't remember doing that nor why on earth I would want to but it is
likely that I did it myself at some point. It also works now with the
shotcut "Session" instead of "System.Web.HttpContext.Current.Session", even
in code-behind.

That is one problem solved. Now I still have to make the session events
(Session_OnStart and Session_OnEnd) kick in. As it is they don't and I do
not see why.

Martin.



Martin said:
Hi,
You might want to open up a trouble ticket with microsoft so they can
take
a
memory dump of your system to see what's wrong.

That seems rather drastic. Fortunately it's not for a mission-critical web
application, I'm only getting proficient with the technology here. And I
think I got one step further.

It I change my code to

<%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>

<%
System.Web.HttpContext.Current.Session.Abandon
%>

I get a different error:

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

So it seems to be a context problem and the initial error messages about
enableSessionState was total baloney.

It appears that Current (a static member of HttpContext of type HttpContext)
is a valid object and that its Session member returns null. Now that isn't
right, is it?

So, did I find a bug? I think I did, I should always have a session.
Apperently on my system ASP.NET has no session for me when I need it.
Moreover, neither Session_OnStart or Session_OnEnd appears to be called. Now
what to think of that? I even renamed them to Session_Start and Session_End
to no avail (some examples use these names instead and I still don't
understand how application events get wired up but that's another matter),

Does this ring a bell with anyone?

Martin.

Here is a link:
http://support.microsoft.com/default.aspx?scid=fh;[ln];oasoem

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
Martin said:
i've copied and pasted your simple page into a new project. i don't get
that error.

That is good to know, thank you.

can you give more informatiton on this? It seems to be specific to a
setting on your computer and not to the framework or the environment
otherwise i would be getting it as well. Makes sense?

About a week ago another guy posted the same problem. Neither of us had
found anything on the matter so it does make sense to assume it is some
local problem. I have it on both my machines though, a Windows Server 2003
and a Windows XP Professional system (to which I copied the lot just to
see the response).

Another page in the same application does allow me to address the session
object. Do I however put the line that increments a session variable
all
Debug="True"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top