473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

2 Simple Questions About Session_Start

Why does Session_Start in Global.asax fire for every page opened during a
session of an ASP.NET application?

Am I wrong to expect that it would fire only when the first page (i.e., any
page in the app that is opened before any other page during the session) is
opened?

Thanks.
Nov 18 '05 #1
6 2465
Sounds like you have....

sessionState mode="Off"

in web.config

or possibly you have this in your page directives <%@ Page...
EnableSessionState="ReadOnly"...

Let me know what you find? Ok?
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Why does Session_Start in Global.asax fire for every page opened during a
session of an ASP.NET application?

Am I wrong to expect that it would fire only when the first page (i.e., any page in the app that is opened before any other page during the session) is opened?

Thanks.

Nov 18 '05 #2
By the way, sessions should only start once and keep a session id that is
accessible by doing response.write(session.sessionid)

The start event will only fire once for the length of your session which is
determined in IIS under your websites Home Directory-Configuration-Options
(default is 20 minutes). Once that expires and your user clicks something,
they will trip the start event and get a new session id, which is bad if you
rely on session variables to store the data in server RAM. Hence, the
improvements to use a state server, sql server, and other ways to maintain
state.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:WB********************@newssvr11.news.prodigy .com...
Sounds like you have....

sessionState mode="Off"

in web.config

or possibly you have this in your page directives <%@ Page...
EnableSessionState="ReadOnly"...

Let me know what you find? Ok?
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Why does Session_Start in Global.asax fire for every page opened during a session of an ASP.NET application?

Am I wrong to expect that it would fire only when the first page (i.e.,

any
page in the app that is opened before any other page during the session)

is
opened?

Thanks.


Nov 18 '05 #3
I checked three things as you suggested - and everything looks good:
1. WebConfig does not have the following entry: [sessionState mode="Off"]
Rather, mode is "InProc"
2. The pages in question do not have the following directive: [@
Page...EnableSessionState="ReadOnly"...]
3. IIS Configuration has the defaults [Enable Session State] checked, with
the timeout default of 20 minutes.

When I add the following line to Session_Start
Response.Write(Session.SessionID);
I get a different value for SessionID on every successive page I open. It
even happens for my login page when I enter invalid credentials and it
simply redisplays the same page. This tells me that it is actually starting
a new session for each page sent to the browser.

FWIW, I'm using VS.NET 2003 on WinXP Pro/SP1, clean install, machine is
stable, IIS is running with defaults installation settings. I have observed
this behavior on two different ASP.NET applications I'm developing on this
machine. Both are C# and use code-behind modules.

Any other ideas?

I really appreciate the help - don't know what else to look at.

-Jeff
"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:dH********************@newssvr11.news.prodigy .com...
By the way, sessions should only start once and keep a session id that is
accessible by doing response.write(session.sessionid)

The start event will only fire once for the length of your session which is determined in IIS under your websites Home Directory-Configuration-Options
(default is 20 minutes). Once that expires and your user clicks something, they will trip the start event and get a new session id, which is bad if you rely on session variables to store the data in server RAM. Hence, the
improvements to use a state server, sql server, and other ways to maintain
state.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:WB********************@newssvr11.news.prodigy .com...
Sounds like you have....

sessionState mode="Off"

in web.config

or possibly you have this in your page directives <%@ Page...
EnableSessionState="ReadOnly"...

Let me know what you find? Ok?
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Why does Session_Start in Global.asax fire for every page opened
during
a session of an ASP.NET application?

Am I wrong to expect that it would fire only when the first page

(i.e., any
page in the app that is opened before any other page during the
session) is
opened?

Thanks.



Nov 18 '05 #4
Anybody have any other ideas? Still having the problem.

If you read only the first sentence of my last reply, it may appear that the
problem is solved - but it's not. That first sentence should continue ...
"everything looks good -but the problem persists..."

I'd appreciate any additional suggestions.


"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
I checked three things as you suggested - and everything looks good:
1. WebConfig does not have the following entry: [sessionState mode="Off"]
Rather, mode is "InProc"
2. The pages in question do not have the following directive: [@
Page...EnableSessionState="ReadOnly"...]
3. IIS Configuration has the defaults [Enable Session State] checked, with
the timeout default of 20 minutes.

When I add the following line to Session_Start
Response.Write(Session.SessionID);
I get a different value for SessionID on every successive page I open. It
even happens for my login page when I enter invalid credentials and it
simply redisplays the same page. This tells me that it is actually starting a new session for each page sent to the browser.

FWIW, I'm using VS.NET 2003 on WinXP Pro/SP1, clean install, machine is
stable, IIS is running with defaults installation settings. I have observed this behavior on two different ASP.NET applications I'm developing on this
machine. Both are C# and use code-behind modules.

Any other ideas?

I really appreciate the help - don't know what else to look at.

-Jeff
"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:dH********************@newssvr11.news.prodigy .com...
By the way, sessions should only start once and keep a session id that is
accessible by doing response.write(session.sessionid)

The start event will only fire once for the length of your session which

is
determined in IIS under your websites Home Directory-Configuration-Options (default is 20 minutes). Once that expires and your user clicks

something,
they will trip the start event and get a new session id, which is bad if

you
rely on session variables to store the data in server RAM. Hence, the
improvements to use a state server, sql server, and other ways to maintain state.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and Access

"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:WB********************@newssvr11.news.prodigy .com...
Sounds like you have....

sessionState mode="Off"

in web.config

or possibly you have this in your page directives <%@ Page...
EnableSessionState="ReadOnly"...

Let me know what you find? Ok?
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server,

and Access

"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
> Why does Session_Start in Global.asax fire for every page opened during
a
> session of an ASP.NET application?
>
> Am I wrong to expect that it would fire only when the first page

(i.e., any
> page in the app that is opened before any other page during the session) is
> opened?
>
> Thanks.
>
>



Nov 18 '05 #5
I have the same problem, My project run on a server with 4
cpu. and when I set mode to stateserver, it's ok, but I
need set some come to session, that don't support by
stateserver.
-----Original Message-----
Anybody have any other ideas? Still having the problem.

If you read only the first sentence of my last reply, it may appear that theproblem is solved - but it's not. That first sentence should continue ..."everything looks good -but the problem persists..."

I'd appreciate any additional suggestions.


"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
I checked three things as you suggested - and everything looks good:
1. WebConfig does not have the following entry: [sessionState mode="Off"] Rather, mode is "InProc"
2. The pages in question do not have the following directive: [@ Page...EnableSessionState="ReadOnly"...]
3. IIS Configuration has the defaults [Enable Session State] checked, with the timeout default of 20 minutes.

When I add the following line to Session_Start
Response.Write(Session.SessionID);
I get a different value for SessionID on every successive page I open. It even happens for my login page when I enter invalid credentials and it simply redisplays the same page. This tells me that it is actually
starting
a new session for each page sent to the browser.

FWIW, I'm using VS.NET 2003 on WinXP Pro/SP1, clean
install, machine is stable, IIS is running with defaults installation settings. I haveobserved
this behavior on two different ASP.NET applications I'm
developing on this machine. Both are C# and use code-behind modules.

Any other ideas?

I really appreciate the help - don't know what else to look at.
-Jeff
"Jerry Boone" <je***@antech.biz.killspam> wrote in message news:dH2Gb.108 $F***********@newssvr11.news.prodigy.com...
> By the way, sessions should only start once and keep a session id thatis
> accessible by doing response.write
(session.sessionid) >
> The start event will only fire once for the length of your session which is
> determined in IIS under your websites HomeDirectory-Configuration-Options > (default is 20 minutes). Once that expires and your
user clicks something,
> they will trip the start event and get a new session
id, which is bad if you
> rely on session variables to store the data in server
RAM. Hence, the > improvements to use a state server, sql server, and other ways to
maintain > state.
>
> --
> Jerry Boone
> Analytical Technologies, Inc.
> http://www.antech.biz
> Secure Hosting and Development Solutions for ASP,
ASP.NET, SQL Server,
and > Access
>
>
>
> "Jerry Boone" <je***@antech.biz.killspam> wrote in

message > news:WB2Gb.106 $G***********@newssvr11.news.prodigy.com... > > Sounds like you have....
> >
> > sessionState mode="Off"
> >
> > in web.config
> >
> > or possibly you have this in your page directives <% @ Page... > > EnableSessionState="ReadOnly"...
> >
> > Let me know what you find? Ok?
> >
> >
> > --
> > Jerry Boone
> > Analytical Technologies, Inc.
> > http://www.antech.biz
> > Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
> > Access
> >
> >
> >
> > "Jeff Smythe" <Sm*******@YaRight.com> wrote in
message > > news:ew**************@TK2MSFTNGP12.phx.gbl...
> > > Why does Session_Start in Global.asax fire for

every page opened during
> a
> > > session of an ASP.NET application?
> > >
> > > Am I wrong to expect that it would fire only when
the first page (i.e.,
> > any
> > > page in the app that is opened before any other
page during the session)
> > is
> > > opened?
> > >
> > > Thanks.
> > >
> > >
> >
> >
>
>


.

Nov 18 '05 #6
> >> > > > Why does Session_Start in Global.asax fire for a session of an
ASP.NET application?
> > > Am I wrong to expect that it would fire only when the first page

Technically, yes you are wrong. It's not necessarily for the first page but
rather session start fires for each new session id generated. That this
happens as a result of a new page request is really coincidental.

Session state is necessarily complex because of the need to service
different state providers. It is possible to have session id be regenerated
for each page within the same application even if the user does not close
the browser or log out - like what you are experiencing. This is by design.
The run-time checks the session dictionary object to determine if it is
written to. If it is not, it generates a new session id which in term fires
the session start event. If it is written to, then the existing session id
is used to service the request. Notice, this isn't page dependent at all.

To plug this behavior, you would need to write an arbitrary value to
session: session["null"] = null; You will then have this session id until
the browser is closed. Calling session abandon or session end will not
reassign a new session id. And session start will be guaranteed to only fire
once within this context.

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
<an*******@discussions.microsoft.com> wrote in message
news:1b****************************@phx.gbl...
I have the same problem, My project run on a server with 4
cpu. and when I set mode to stateserver, it's ok, but I
need set some come to session, that don't support by
stateserver.
-----Original Message-----
Anybody have any other ideas? Still having the problem.

If you read only the first sentence of my last reply, it

may appear that the
problem is solved - but it's not. That first sentence

should continue ...
"everything looks good -but the problem persists..."

I'd appreciate any additional suggestions.


"Jeff Smythe" <Sm*******@YaRight.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
I checked three things as you suggested - and

everything looks good: 1. WebConfig does not have the following entry: [sessionState mode="Off"] Rather, mode is "InProc"
2. The pages in question do not have the following directive: [@ Page...EnableSessionState="ReadOnly"...]
3. IIS Configuration has the defaults [Enable Session State] checked, with the timeout default of 20 minutes.

When I add the following line to Session_Start
Response.Write(Session.SessionID);
I get a different value for SessionID on every successive page I open. It even happens for my login page when I enter invalid credentials and it simply redisplays the same page. This tells me that it is actually
starting
a new session for each page sent to the browser.

FWIW, I'm using VS.NET 2003 on WinXP Pro/SP1, clean

install, machine is stable, IIS is running with defaults installation settings. I have
observed
this behavior on two different ASP.NET applications I'm

developing on this machine. Both are C# and use code-behind modules.

Any other ideas?

I really appreciate the help - don't know what else to look at.
-Jeff
"Jerry Boone" <je***@antech.biz.killspam> wrote in message news:dH2Gb.108 $F***********@newssvr11.news.prodigy.com... > By the way, sessions should only start once and keep a session id that
is
> accessible by doing response.write

(session.sessionid) >
> The start event will only fire once for the length of your session which is
> determined in IIS under your websites Home

Directory-Configuration-Options
> (default is 20 minutes). Once that expires and your user clicks something,
> they will trip the start event and get a new session id, which is bad if you
> rely on session variables to store the data in server RAM. Hence, the > improvements to use a state server, sql server, and other ways to
maintain
> state.
>
> --
> Jerry Boone
> Analytical Technologies, Inc.
> http://www.antech.biz
> Secure Hosting and Development Solutions for ASP,

ASP.NET, SQL Server,
and
> Access
>
>
>
> "Jerry Boone" <je***@antech.biz.killspam> wrote in

message > news:WB2Gb.106 $G***********@newssvr11.news.prodigy.com... > > Sounds like you have....
> >
> > sessionState mode="Off"
> >
> > in web.config
> >
> > or possibly you have this in your page directives <% @ Page... > > EnableSessionState="ReadOnly"...
> >
> > Let me know what you find? Ok?
> >
> >
> > --
> > Jerry Boone
> > Analytical Technologies, Inc.
> > http://www.antech.biz
> > Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
> > Access
> >
> >
> >
> > "Jeff Smythe" <Sm*******@YaRight.com> wrote in message > > news:ew**************@TK2MSFTNGP12.phx.gbl...
> > > Why does Session_Start in Global.asax fire for every page opened during
> a
> > > session of an ASP.NET application?
> > >
> > > Am I wrong to expect that it would fire only when the first page (i.e.,
> > any
> > > page in the app that is opened before any other page during the session)
> > is
> > > opened?
> > >
> > > Thanks.
> > >
> > >
> >
> >
>
>

.

Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Mateer | last post by:
Hi Why does the following code allow me to keep the same session when in the same sub domain (ie admin.localhost), yet not when I goto another related domain eg main.localhost? I would like...
3
by: Florence HENRY | last post by:
Hello, I've searched about my problem on google before posting, but I didn't find anything relevant... I have a problem with session_start. Here is my code : <html> <head> <?php...
2
by: Reply-Via-Newsgroup Thanks | last post by:
Folks, I consider myself a reasonably strong PHP programmer, but I've not used sessions before (I've used cookies instead) and I'd appreciate it if someone could confirm something for me. ...
3
by: Trogdor | last post by:
I set up a server on an AMD 650 machine running gentoo linux. I installed Apachie 2, MySQL 4.1 and PHP 4.3.11 I use another computer on my local net (192.168.0.x) to access the server as a...
1
by: Mercy | last post by:
Hi, I'm a newbie. I was trying to figure out how to use the Session_start method? The reference books I'm reading say that a session STARTS when "session_start" is called. But ... in their sample...
8
by: lkrubner | last post by:
I was trying to set a cookie before I called session_start() and it was giving me an error. But isn't sessions really just a cookie? Why would it matter if I sent a cookie before session_start? Can...
5
by: Niklas Uhlin | last post by:
Someone please explain why Session_Start fires multiple times / retains SessionID values between sessions, when you open an ASP.NET page from MS Word. For details of the problem, see below: 1....
5
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.