Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > enableSessionState - still struggling

Reply
Thread Tools

enableSessionState - still struggling

 
 
Martin
Guest
Posts: n/a
 
      12-26-2003
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.


 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      12-26-2003
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

"Martin" <(E-Mail Removed)> wrote in message
news:3fec6a9c$0$143$(E-Mail Removed)4all. nl...
> 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.
>
>



 
Reply With Quote
 
 
 
 
Alvin Bruney
Guest
Posts: n/a
 
      12-26-2003
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?

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
"Martin" <(E-Mail Removed)> wrote in message
news:3fec6a9c$0$143$(E-Mail Removed)4all. nl...
> 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.
>
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      12-26-2003
> 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.


 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      12-26-2003
> 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.

> > 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.
> >
> >

>
>



 
Reply With Quote
 
Alvin Bruney
Guest
Posts: n/a
 
      12-27-2003
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

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
"Martin" <(E-Mail Removed)> wrote in message
news:3feca9b4$0$149$(E-Mail Removed)4all. nl...
> > 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.
>
> > > 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.
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      12-29-2003
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" <(E-Mail Removed)> wrote in message
news:3fef3ec4$0$137$(E-Mail Removed)4all .nl...
> 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" <(E-Mail Removed)> wrote in message
> > news:3feca9b4$0$149$(E-Mail Removed)4all. nl...
> > > > 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.
> > >
> > > > > 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.

> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AMD still struggling Mickey Mouse NZ Computing 4 01-19-2008 11:25 AM
still struggling, howto use a list-element as a name ? Stef Mientki Python 12 01-07-2007 05:43 PM
Session state can only be used when EnableSessionState is set to true... error John Baughman ASP .Net 6 12-24-2003 06:50 AM
RE: Can't use Session in ASP.NET - enableSessionState error Jim Cheshire [MSFT] ASP .Net 3 08-04-2003 04:27 PM
enablesessionstate Page directive is needed to use the Session object Marco Gerlach ASP .Net 2 07-18-2003 10:27 AM



Advertisments