By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Session_Start and Microsoft Word 2002 bug?

P: n/a
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. Create a new C# ASP.NET web application named "demo" and modify
Session_Start in Global.asax.cs as follows:

protected void Session_Start(Object sender, EventArgs e)
{
Response.Write("Session_Start event fired at "+
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss<BR><BR>"));
}

2. Modify Page_Load in WebForm1.aspx.cs as follows:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("SESSION ID = "+ Session.SessionID +"<BR><BR>");
Response.Write("<A HREF=\"WebForm1.aspx\">Reload
page</A><BR><BR>");
}

3. Build the project.
4. Open Internet Explorer and navigate to
http://localhost/demo/WebForm1.aspx.
You should see the following text:

Session_Start event fired at <YYYY-MM-DD HH:MM:SS>
Session Id = <XXX>

And if you click the "reload page" link, the "Session_Start" text
should disappear (because Session_Start has already been fired). The
"Session Id" text, however, should remain and have the same value
(because we're still in the same session).

Now, that is how it *should* be working. However, if you close all
Internet Explorer windows and replace step 4 with the following,
that's when things start to behave really weird...
1. If Microsoft Word 2002 is open exit the program.
2. If Internet Explorer is open exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session
Id.
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window!

Another, even more interesting twist to the same problem surfaces if
you replace step 4 with the following:

1. If Microsoft Word 2002 is open exit the program.
2. If Internet Explorer is open exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session Id
(write down these values for comparison later on).
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window
(write down these values for comparison later on)!
8. Close Internet Explorer but leave Microsoft Word 2002 running.
9. Click the link again, thereby opening WebForm1.aspx in a new
Internet Explorer window.
10. Notice how Session_Start *appears* to fire anew, but how both the
time stamp and the Session Id retain the values as before you closed
Internet Explorer!
What the heck is going on here?

Brgds,

Niklas Uhlin
System Developer
CSC
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
http://www.csharphelp.com/archives3/archive540.html

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Niklas Uhlin" <so*************@hotmail.com> wrote in message
news:af**************************@posting.google.c om...
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. Create a new C# ASP.NET web application named "demo" and modify
Session_Start in Global.asax.cs as follows:

protected void Session_Start(Object sender, EventArgs e)
{
Response.Write("Session_Start event fired at "+
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss<BR><BR>"));
}

2. Modify Page_Load in WebForm1.aspx.cs as follows:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("SESSION ID = "+ Session.SessionID +"<BR><BR>");
Response.Write("<A HREF=\"WebForm1.aspx\">Reload
page</A><BR><BR>");
}

3. Build the project.
4. Open Internet Explorer and navigate to
http://localhost/demo/WebForm1.aspx.
You should see the following text:

Session_Start event fired at <YYYY-MM-DD HH:MM:SS>
Session Id = <XXX>

And if you click the "reload page" link, the "Session_Start" text
should disappear (because Session_Start has already been fired). The
"Session Id" text, however, should remain and have the same value
(because we're still in the same session).

Now, that is how it *should* be working. However, if you close all
Internet Explorer windows and replace step 4 with the following,
that's when things start to behave really weird...
1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session
Id.
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window!

Another, even more interesting twist to the same problem surfaces if
you replace step 4 with the following:

1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session Id
(write down these values for comparison later on).
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window
(write down these values for comparison later on)!
8. Close Internet Explorer but leave Microsoft Word 2002 running.
9. Click the link again, thereby opening WebForm1.aspx in a new
Internet Explorer window.
10. Notice how Session_Start *appears* to fire anew, but how both the
time stamp and the Session Id retain the values as before you closed
Internet Explorer!
What the heck is going on here?

Brgds,

Niklas Uhlin
System Developer
CSC

Nov 18 '05 #2

P: n/a
> http://www.csharphelp.com/archives3/archive540.html

How does this explain the fact that even though *all* MSIE windows
have been closed, Session_Start appears to fire anew, but the Session
ID retains the value it had prior to closing all the windows, if you
reopen the page from Word?

There's got to be something wrong here?

Brgds,

Niklas
Nov 18 '05 #3

P: n/a
Ok, I'll take a closer look at it this weekend

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Niklas Uhlin" <so*************@hotmail.com> wrote in message
news:af**************************@posting.google.c om...
http://www.csharphelp.com/archives3/archive540.html


How does this explain the fact that even though *all* MSIE windows
have been closed, Session_Start appears to fire anew, but the Session
ID retains the value it had prior to closing all the windows, if you
reopen the page from Word?

There's got to be something wrong here?

Brgds,

Niklas

Nov 18 '05 #4

P: n/a
I don't have word 02. i substituted word 03 for it. i get the same results
as u. here is my analysis.
1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session
Id.
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window!

Another, even more interesting twist to the same problem surfaces if
you replace step 4 with the following:
I believe MS Word generated links are handled differently that other
applications so that a link which fires from MS Word is considered one
session, but clicking the link inside the aspx page generates another
session because the second click does not originate from inside MS Word.
MSWord for one, aspx page for the other. I've concluded this because,
substituting MS Word for Outlook Express for example yields different
results.

1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session Id
(write down these values for comparison later on).
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window
(write down these values for comparison later on)!
8. Close Internet Explorer but leave Microsoft Word 2002 running.
9. Click the link again, thereby opening WebForm1.aspx in a new
Internet Explorer window.
10. Notice how Session_Start *appears* to fire anew, but how both the
time stamp and the Session Id retain the values as before you closed
Internet Explorer!
This is a bit wierd but actually what is going on is IE is caching the
result of the page on the first pass. Even if the second pass fires a new
window and a new session id, IE chooses to display the old results because
of caching. You will find that this fails to happen if you clear your cache
or if you disable caching programmatically using
Response.Cache.SetCacheability(HttpCacheability.Se rverAndNoCache); I'm not
convinced that the caching needs to happen since the request is new but it
does seem to happen consistently with MS Word. This behavior does not happen
in Outlook.

A bug? Not sure. I'm not sure because i don't know how the architecture is
built for referrers which originate from MS Word as opposed to other
clients.
I'm keeping this thread so that the whidbey people can have a more
consistent behavior for whidbey.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Niklas Uhlin" <so*************@hotmail.com> wrote in message
news:af**************************@posting.google.c om... 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. Create a new C# ASP.NET web application named "demo" and modify
Session_Start in Global.asax.cs as follows:

protected void Session_Start(Object sender, EventArgs e)
{
Response.Write("Session_Start event fired at "+
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss<BR><BR>"));
}

2. Modify Page_Load in WebForm1.aspx.cs as follows:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("SESSION ID = "+ Session.SessionID +"<BR><BR>");
Response.Write("<A HREF=\"WebForm1.aspx\">Reload
page</A><BR><BR>");
}

3. Build the project.
4. Open Internet Explorer and navigate to
http://localhost/demo/WebForm1.aspx.
You should see the following text:

Session_Start event fired at <YYYY-MM-DD HH:MM:SS>
Session Id = <XXX>

And if you click the "reload page" link, the "Session_Start" text
should disappear (because Session_Start has already been fired). The
"Session Id" text, however, should remain and have the same value
(because we're still in the same session).

Now, that is how it *should* be working. However, if you close all
Internet Explorer windows and replace step 4 with the following,
that's when things start to behave really weird...
1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session
Id.
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window!

Another, even more interesting twist to the same problem surfaces if
you replace step 4 with the following:

1. If Microsoft Word 2002 is open - exit the program.
2. If Internet Explorer is open - exit the program.
3. Open Microsoft Word 2002
4. Type the following into a new document:
http://localhost/demo/WebForm1.aspx.
5. Click the link, thereby opening WebForm1.aspx in a new Internet
Explorer window.
6. Notice how Session_Start fires and how you're assigned a Session Id
(write down these values for comparison later on).
7. Now click the "reload page" link and notice how Session_Start is
fired again(!) and how you're assigned a brand new Session Id(!) even
though the page is reloaded in the same Internet Explorer window
(write down these values for comparison later on)!
8. Close Internet Explorer but leave Microsoft Word 2002 running.
9. Click the link again, thereby opening WebForm1.aspx in a new
Internet Explorer window.
10. Notice how Session_Start *appears* to fire anew, but how both the
time stamp and the Session Id retain the values as before you closed
Internet Explorer!
What the heck is going on here?

Brgds,

Niklas Uhlin
System Developer
CSC

Nov 18 '05 #5

P: n/a
Thank you!!

I think Response.Cache.SetCacheability(HttpCacheability.Se rverAndNoCache)
will solve our problem =)

Brgds,

Niklas
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.