Session_Start and Microsoft Word 2002 bug?

N

Niklas Uhlin

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
 
N

Niklas Uhlin

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
 
A

Alvin Bruney [MVP]

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.ServerAndNoCache); 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.
 
N

Niklas Uhlin

Thank you!!

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

Brgds,

Niklas
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top