469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

GLOBAL.ASA and IIS 6.0

Hi there,

How does IIS 6.0 treat the global.asa file? I had the following problem;

1. uploaded a new site to the win3k server
2. had incorrect db connection string in Session_OnStart in global.asa and
website caused errors.
3. Changed the global.asa file to include the correct details. Saved the
file. Still got the same errors.

I could not resolve this unless restarting the WWW Service on this server.
In IIS 5.0 the global.asa file would reload after resaving it (as the
timestamp is updated).

I even waited the next day before restarting the service because I though
Session_OnStart expires after my session ends...but the error was still there
in the morning.

Hopefully someone will make sense of it for me. Here is the code (I
inherited) in the global.asa
Sub Application_OnStart
Application("DB.ConnectionString") = ""
Application("MaxLoginAttempts") = 5
Set Application("Con") = Server.CreateObject("ADODB.Connection")
Session("Test") = Now()
End Sub
Sub Session_OnStart

Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

'changed db connection application var to SQL server

Session("LoginAttempts") = 0

Session("XAN_ConnectionString") = Application("DB_ConnectionString")
Session("XAN_adminConnectionString") = Application("DB_ConnectionString")

Session("XAN_ConnectionTimeout") = 15
Session("XAN_CommandTimeout") = 30
Session("XAN_CursorLocation") = 3

Set Session("Con") = Server.CreateObject("ADODB.Connection")
Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

Response.Buffer = true
if Application("Con").State = 0 then
Application("Con").Open Session("XAN_ConnectionString")
end if
'************************************************* ********************************
End Sub
Jul 19 '05 #1
7 6387
Why are you opening an ADO connection and storing it in Session scope?
That's a really bad way of developing ASP/ADO based applications.
Seriously - you should instantiate and open the connection on each page, and
close and dispose of it on each page. This enables your application to take
advantage of connection pooling. The way you are currently doing it is
really bad - it's not scalable whatsoever.

Suggest you tell us what your errors are to troubleshoot your global.asa
problems (may not have anything to do with global.asa itself - maybe you
have a permissions issue or similar so you need to tweak permissions).

Cheers
Ken
"Matt Calhoon" <ma**@community.nospam> wrote in message
news:2F**********************************@microsof t.com...
Hi there,

How does IIS 6.0 treat the global.asa file? I had the following problem;

1. uploaded a new site to the win3k server
2. had incorrect db connection string in Session_OnStart in global.asa and
website caused errors.
3. Changed the global.asa file to include the correct details. Saved the
file. Still got the same errors.

I could not resolve this unless restarting the WWW Service on this server.
In IIS 5.0 the global.asa file would reload after resaving it (as the
timestamp is updated).

I even waited the next day before restarting the service because I though
Session_OnStart expires after my session ends...but the error was still
there
in the morning.

Hopefully someone will make sense of it for me. Here is the code (I
inherited) in the global.asa
Sub Application_OnStart
Application("DB.ConnectionString") = ""
Application("MaxLoginAttempts") = 5
Set Application("Con") = Server.CreateObject("ADODB.Connection")
Session("Test") = Now()
End Sub
Sub Session_OnStart

Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

'changed db connection application var to SQL server

Session("LoginAttempts") = 0

Session("XAN_ConnectionString") = Application("DB_ConnectionString")
Session("XAN_adminConnectionString") = Application("DB_ConnectionString")

Session("XAN_ConnectionTimeout") = 15
Session("XAN_CommandTimeout") = 30
Session("XAN_CursorLocation") = 3

Set Session("Con") = Server.CreateObject("ADODB.Connection")
Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

Response.Buffer = true
if Application("Con").State = 0 then
Application("Con").Open Session("XAN_ConnectionString")
end if
'************************************************* ********************************
End Sub

Jul 19 '05 #2
Hi Ken,

thanks for your email.

I mentioned in my post that I inherited the code (from another web
development company), and for time constraints cannot be changed. This site
(along with 200 others) is being moved to a new webfarm (which has IIS 6.0).
I can't be fixing all the code for each site unless I have nothing to do for
6 months.

....ok so my question remains; Does IIS 6.0 treat global.asa any different to
IIS 5.0?
Suggest you tell us what your errors are to troubleshoot your global.asa
problems
The error was "incorrect login for user 'mydatabaseuser'. After I changed
the login to the correct password, the change did not take place unless I
restarted the www service (the next day). So it looks as though the
global.asa file is cached until restart of www.


"Ken Schaefer" wrote:
Why are you opening an ADO connection and storing it in Session scope?
That's a really bad way of developing ASP/ADO based applications.
Seriously - you should instantiate and open the connection on each page, and
close and dispose of it on each page. This enables your application to take
advantage of connection pooling. The way you are currently doing it is
really bad - it's not scalable whatsoever.

Suggest you tell us what your errors are to troubleshoot your global.asa
problems (may not have anything to do with global.asa itself - maybe you
have a permissions issue or similar so you need to tweak permissions).

Cheers
Ken
"Matt Calhoon" <ma**@community.nospam> wrote in message
news:2F**********************************@microsof t.com...
Hi there,

How does IIS 6.0 treat the global.asa file? I had the following problem;

1. uploaded a new site to the win3k server
2. had incorrect db connection string in Session_OnStart in global.asa and
website caused errors.
3. Changed the global.asa file to include the correct details. Saved the
file. Still got the same errors.

I could not resolve this unless restarting the WWW Service on this server.
In IIS 5.0 the global.asa file would reload after resaving it (as the
timestamp is updated).

I even waited the next day before restarting the service because I though
Session_OnStart expires after my session ends...but the error was still
there
in the morning.

Hopefully someone will make sense of it for me. Here is the code (I
inherited) in the global.asa
Sub Application_OnStart
Application("DB.ConnectionString") = ""
Application("MaxLoginAttempts") = 5
Set Application("Con") = Server.CreateObject("ADODB.Connection")
Session("Test") = Now()
End Sub
Sub Session_OnStart

Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

'changed db connection application var to SQL server

Session("LoginAttempts") = 0

Session("XAN_ConnectionString") = Application("DB_ConnectionString")
Session("XAN_adminConnectionString") = Application("DB_ConnectionString")

Session("XAN_ConnectionTimeout") = 15
Session("XAN_CommandTimeout") = 30
Session("XAN_CursorLocation") = 3

Set Session("Con") = Server.CreateObject("ADODB.Connection")
Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

Response.Buffer = true
if Application("Con").State = 0 then
Application("Con").Open Session("XAN_ConnectionString")
end if
'************************************************* ********************************
End Sub


Jul 19 '05 #3
That is perfectly normal to have to restart the IIS service after making
changes to the global.asa file.

I remember when I was doing web development on IIS 4 I had to restart
the IIS service to get the changes in my global.asa to take effect.

Matt Calhoon wrote:
Suggest you tell us what your errors are to troubleshoot your global.asa
problems

The error was "incorrect login for user 'mydatabaseuser'. After I changed
the login to the correct password, the change did not take place unless I
restarted the www service (the next day). So it looks as though the
global.asa file is cached until restart of www.


Jul 19 '05 #4
That is *not* normal.

IIS should be aware of changes to global.asa file (via Windows File Change
Notification), and then the application is restarted. This was always
potential source of problems in ASP apps (because if a developer "touched"
the global.asa file, then the app would be restarted, and all existing user
sessions would be lost)

Cheers
Ken
"joker" <no*****@netzero.com> wrote in message
news:el*************@TK2MSFTNGP11.phx.gbl...
That is perfectly normal to have to restart the IIS service after making
changes to the global.asa file.

I remember when I was doing web development on IIS 4 I had to restart the
IIS service to get the changes in my global.asa to take effect.

Matt Calhoon wrote:
Suggest you tell us what your errors are to troubleshoot your global.asa
problems

The error was "incorrect login for user 'mydatabaseuser'. After I
changed the login to the correct password, the change did not take place
unless I restarted the www service (the next day). So it looks as though
the global.asa file is cached until restart of www.

Jul 19 '05 #5
Hi,

At the moment you are opening a separate connection for each individual
user, and holding it open *even* when the connection is not being used.
Additionally, the connection is not being released until the session times
out. For a large application, with connection pooling, you should not need
more than 20-30 connections, however your application is going to result in
hundreds of connections. SQL Server (nor any other DBMS) won't scale to
hundreds, or thousands of concurrent connections.

What I suggest you do is write a little function that returns an open
connection, and stick that into every page you have (via find-n-replace).
Then all you need to do is change all references to Session("Con") to this
page level connnection.

I also noticed just now that you are attempting to open, and store an ADO
connection in Application scope! That's just as bad - that means you are
serialising all access to your database through a single connection whenever
you try to use that. I have no idea who wrote this application before, but
that's just about the worst way to write anything (unless you are using that
one connection to keep a connection persistantly in the OLEDB/ODBC pool, but
you shouldn't need to do that on a high-load app anyway). This is a really
good resource on pooling:
http://msdn.microsoft.com/library/de...l/pooling2.asp

Cheers
Ken

"Matt Calhoon" <ma**@community.nospam> wrote in message
news:60**********************************@microsof t.com...
Hi Ken,

thanks for your email.

I mentioned in my post that I inherited the code (from another web
development company), and for time constraints cannot be changed. This
site
(along with 200 others) is being moved to a new webfarm (which has IIS
6.0).
I can't be fixing all the code for each site unless I have nothing to do
for
6 months.

...ok so my question remains; Does IIS 6.0 treat global.asa any different
to
IIS 5.0?
Suggest you tell us what your errors are to troubleshoot your global.asa
problems


The error was "incorrect login for user 'mydatabaseuser'. After I changed
the login to the correct password, the change did not take place unless I
restarted the www service (the next day). So it looks as though the
global.asa file is cached until restart of www.


"Ken Schaefer" wrote:
Why are you opening an ADO connection and storing it in Session scope?
That's a really bad way of developing ASP/ADO based applications.
Seriously - you should instantiate and open the connection on each page,
and
close and dispose of it on each page. This enables your application to
take
advantage of connection pooling. The way you are currently doing it is
really bad - it's not scalable whatsoever.

Suggest you tell us what your errors are to troubleshoot your global.asa
problems (may not have anything to do with global.asa itself - maybe you
have a permissions issue or similar so you need to tweak permissions).

Cheers
Ken
"Matt Calhoon" <ma**@community.nospam> wrote in message
news:2F**********************************@microsof t.com...
> Hi there,
>
> How does IIS 6.0 treat the global.asa file? I had the following
> problem;
>
> 1. uploaded a new site to the win3k server
> 2. had incorrect db connection string in Session_OnStart in global.asa
> and
> website caused errors.
> 3. Changed the global.asa file to include the correct details. Saved
> the
> file. Still got the same errors.
>
> I could not resolve this unless restarting the WWW Service on this
> server.
> In IIS 5.0 the global.asa file would reload after resaving it (as the
> timestamp is updated).
>
> I even waited the next day before restarting the service because I
> though
> Session_OnStart expires after my session ends...but the error was still
> there
> in the morning.
>
> Hopefully someone will make sense of it for me. Here is the code (I
> inherited) in the global.asa
>
>
> Sub Application_OnStart
> Application("DB.ConnectionString") = ""
> Application("MaxLoginAttempts") = 5
> Set Application("Con") = Server.CreateObject("ADODB.Connection")
> Session("Test") = Now()
> End Sub
>
>
> Sub Session_OnStart
>
>
>
> Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
> Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
> Password=mypassword"
>
> 'changed db connection application var to SQL server
>
> Session("LoginAttempts") = 0
>
> Session("XAN_ConnectionString") = Application("DB_ConnectionString")
> Session("XAN_adminConnectionString") =
> Application("DB_ConnectionString")
>
> Session("XAN_ConnectionTimeout") = 15
> Session("XAN_CommandTimeout") = 30
> Session("XAN_CursorLocation") = 3
>
> Set Session("Con") = Server.CreateObject("ADODB.Connection")
> Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
> Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
>
>
> Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
> Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
> Password=mypassword"
>
> Response.Buffer = true
>
>
> if Application("Con").State = 0 then
> Application("Con").Open Session("XAN_ConnectionString")
> end if
>
>
> '************************************************* ********************************
> End Sub
>
>


Jul 19 '05 #6
write yourself a "reload.asp" script that contains the same code as in
global.asa (change global.asa then copy/paste to reload.asp).

Note all of the other suggestions regarding session-scope objects and
especially the application-scope connection object that will cause you no
end of trouble later. You might want to bite the bullet and fix it now (tell
the boss that porting to win 2003 requires some changes if you have to).

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Matt Calhoon" <ma**@community.nospam> wrote in message
news:2F**********************************@microsof t.com...
Hi there,

How does IIS 6.0 treat the global.asa file? I had the following problem;

1. uploaded a new site to the win3k server
2. had incorrect db connection string in Session_OnStart in global.asa and
website caused errors.
3. Changed the global.asa file to include the correct details. Saved the
file. Still got the same errors.

I could not resolve this unless restarting the WWW Service on this server.
In IIS 5.0 the global.asa file would reload after resaving it (as the
timestamp is updated).

I even waited the next day before restarting the service because I though
Session_OnStart expires after my session ends...but the error was still there in the morning.

Hopefully someone will make sense of it for me. Here is the code (I
inherited) in the global.asa
Sub Application_OnStart
Application("DB.ConnectionString") = ""
Application("MaxLoginAttempts") = 5
Set Application("Con") = Server.CreateObject("ADODB.Connection")
Session("Test") = Now()
End Sub
Sub Session_OnStart

Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

'changed db connection application var to SQL server

Session("LoginAttempts") = 0

Session("XAN_ConnectionString") = Application("DB_ConnectionString")
Session("XAN_adminConnectionString") = Application("DB_ConnectionString")

Session("XAN_ConnectionTimeout") = 15
Session("XAN_CommandTimeout") = 30
Session("XAN_CursorLocation") = 3

Set Session("Con") = Server.CreateObject("ADODB.Connection")
Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
Password=mypassword"

Response.Buffer = true
if Application("Con").State = 0 then
Application("Con").Open Session("XAN_ConnectionString")
end if
'************************************************* **************************
****** End Sub

Jul 19 '05 #7
On Tue, 14 Sep 2004 20:57:07 -0700, Matt Calhoon
<ma**@community.nospam> wrote:
Hi Ken,

thanks for your email.

I mentioned in my post that I inherited the code (from another web
development company), and for time constraints cannot be changed. This site
(along with 200 others) is being moved to a new webfarm (which has IIS 6.0).
I can't be fixing all the code for each site unless I have nothing to do for
6 months.

...ok so my question remains; Does IIS 6.0 treat global.asa any different to
IIS 5.0?
Probably, but not in relation to what you describe. When the
global.asa is changed, it should reflect in your apps just as it did
in IIS5.
Suggest you tell us what your errors are to troubleshoot your global.asa
problems


The error was "incorrect login for user 'mydatabaseuser'. After I changed
the login to the correct password, the change did not take place unless I
restarted the www service (the next day). So it looks as though the
global.asa file is cached until restart of www.


It shouldn't be, and certainly not until the next day. But the server
or client may have cached something that did affect this, it's
impossible to say without a lot more details.

But since changing global.asa drops sessions anyway, it wouldn't be a
stretch to simply do a restart of the app or site, or IIS itself
(depends on what your apps do, and how your sites are configured...).

Jeff
"Ken Schaefer" wrote:
Why are you opening an ADO connection and storing it in Session scope?
That's a really bad way of developing ASP/ADO based applications.
Seriously - you should instantiate and open the connection on each page, and
close and dispose of it on each page. This enables your application to take
advantage of connection pooling. The way you are currently doing it is
really bad - it's not scalable whatsoever.

Suggest you tell us what your errors are to troubleshoot your global.asa
problems (may not have anything to do with global.asa itself - maybe you
have a permissions issue or similar so you need to tweak permissions).

Cheers
Ken
"Matt Calhoon" <ma**@community.nospam> wrote in message
news:2F**********************************@microsof t.com...
> Hi there,
>
> How does IIS 6.0 treat the global.asa file? I had the following problem;
>
> 1. uploaded a new site to the win3k server
> 2. had incorrect db connection string in Session_OnStart in global.asa and
> website caused errors.
> 3. Changed the global.asa file to include the correct details. Saved the
> file. Still got the same errors.
>
> I could not resolve this unless restarting the WWW Service on this server.
> In IIS 5.0 the global.asa file would reload after resaving it (as the
> timestamp is updated).
>
> I even waited the next day before restarting the service because I though
> Session_OnStart expires after my session ends...but the error was still
> there
> in the morning.
>
> Hopefully someone will make sense of it for me. Here is the code (I
> inherited) in the global.asa
>
>
> Sub Application_OnStart
> Application("DB.ConnectionString") = ""
> Application("MaxLoginAttempts") = 5
> Set Application("Con") = Server.CreateObject("ADODB.Connection")
> Session("Test") = Now()
> End Sub
>
>
> Sub Session_OnStart
>
>
>
> Application("DB_ConnectionString") = "Provider=SQLOLEDB; Data
> Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
> Password=mypassword"
>
> 'changed db connection application var to SQL server
>
> Session("LoginAttempts") = 0
>
> Session("XAN_ConnectionString") = Application("DB_ConnectionString")
> Session("XAN_adminConnectionString") = Application("DB_ConnectionString")
>
> Session("XAN_ConnectionTimeout") = 15
> Session("XAN_CommandTimeout") = 30
> Session("XAN_CursorLocation") = 3
>
> Set Session("Con") = Server.CreateObject("ADODB.Connection")
> Session("Con").ConnectionTimeout = Session("XAN_ConnectionTimeout")
> Session("Con").CommandTimeout = Session("XAN_CommandTimeout")
>
>
> Session("XAN_ConnectionString") = "Provider=SQLOLEDB; Data
> Source=myDBServer; Initial Catalog=DatabaseName; User ID=sa;
> Password=mypassword"
>
> Response.Buffer = true
>
>
> if Application("Con").State = 0 then
> Application("Con").Open Session("XAN_ConnectionString")
> end if
>
>
> '************************************************* ********************************
> End Sub
>
>



Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by David Hitillambeau | last post: by
1 post views Thread by Andr? Roberge | last post: by
10 posts views Thread by David P. Donahue | last post: by
22 posts views Thread by fd123456 | last post: by
8 posts views Thread by Rob T | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.