am i understanding this correctly

G

Guest

hey all,

i have a simple app that references the web.config.
i browse to the page.
i changed the web.config.
i do a postback to the page,
And session is gone.

Only after i close the browser
and reopen it start working with the new settings.

am i understanding this correctly?

thanks,
rodchar
 
P

Peter Rilling

Yes, here is what happens.

Each application lives in an AppDomain loaded into the CLR. The AppDomain
hosts the common variables such as Session and Application. When the
AppDomain first loads (like the first time you visit a site), the web.config
is loaded. When the web.config changes, ASP.NET monitors this and recycles
the AppDomain causing all variables to be lost. This is how the new
web.config is loaded again.

It is similar to a regular application where if the app.config changes, the
application will need to be closed and restarted.
 
J

Juan T. Llibre

Just a small precision...

re:
i have a simple app that references the web.config.
i browse to the page.
i changed the web.config.
i do a postback to the page,
And session is gone.

True.

The Application and the Sessions will restart
if you update either web.config or global.asax.

re:
Only after i close the browser
and reopen it start working with the new settings.

No.

The new settings apply immediately after the Application restarts,
and are not dependent on the browser having been closed.

Remember that the Session changes are made server-side
and do *not* depend on whether the browser has been closed or not.

What you *will* see is that IE will continue to use the same Session ID.

For a new Session ID to be used by IE,
the browser must be closed and reopened.

IE *does not* recycle the Session ID number until the browser is closed
but *all* your Server's session variables will start afresh.

Regardless of whether you close the browser, or not,
you *do* have a fresh set of session variables to work with
if you make a change to either global.asax or web.config.

This is real easy to test for.

Run this script as Sessiontest.aspx :
-----------------------------------------------------
<%@ Page Language="VB" %>
<html>
<head>
</head>
<body>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Response.Write("Session ID : " & Session.SessionID)
Response.Write("<br />")
Session.Contents("SessionStartTime") = Now
Response.Write("<br />")
Dim Item as String
For Each Item In Session.Contents
Response.Write (Item & " = " & Session(Item))
Response.Write ("<br>")
Next
End Sub
</script>
</body>
</html>
-----------------------------------------------------

After you run it, you will see the SessionID and the SessionStartTime
session variable.

If you now update either web.config or global.asax and refresh the page,
you will see the same Session ID, but a fresh start time.

The Session ID has been recycled, but you're in a new session.

If you then close the browser and reopen it, you will see
a new Session ID *and* a fresh start time.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top