473,395 Members | 1,502 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,395 software developers and data experts.

Page uload occurs two times when redirecting

Hi,

I'm overriding OnUload in my pages. I've put the Connection.Close in the
method.
But I have noticed that the method is run twice if I do a Response.Redirect
in the page.
Do some one know why?

cheers,
mortb
Nov 19 '05 #1
5 1088
I'm not sure what your problem is; But I'd like to comment on your approach
to database connection management. I'd suggest not opening a connection early
and closing it late as it seems you're doing in the page. I'd suggest instead
opening it late and closing it early. IOW, open the connection right when
you need it, use it (get your data, update, whatever), then close it right
there and then (in your Page_Load or Button_Click or whereever). Connections
are pooled so in a miltiuser environment like ASP.NET you'll have good chances
of reusing open connections that have been put back into the pool.

Also, it helps to make sure that you never have any idle connections. If
you open the connection in Page_Load, say, and close it in Unload... well,
there are cycles where the connection is doing nothing, but it's allocated
and owned by your page an unusable to anyone else. So putting it back in
the pool ASAP let others use it and you end up using fewer connections at
the same time.

Lastly, opening late and closing early makes for less buggy code and less
chances for a leak of the connection.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

I'm overriding OnUload in my pages. I've put the Connection.Close in
the
method.
But I have noticed that the method is run twice if I do a
Response.Redirect
in the page.
Do some one know why?
cheers,
mortb


Nov 19 '05 #2
Good Advice! I wonder if Mortb is an ex Windows Developer, they seem to
think like that?
Nov 19 '05 #3
Or better still implement your connection management in a seperate layer
that closes the connection after the command is executed and have nodb
management code in your Page_Load or Button_Click events :)

MattC

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:40**********************@msnews.microsoft.com ...
I'm not sure what your problem is; But I'd like to comment on your
approach to database connection management. I'd suggest not opening a
connection early and closing it late as it seems you're doing in the page.
I'd suggest instead opening it late and closing it early. IOW, open the
connection right when you need it, use it (get your data, update,
whatever), then close it right there and then (in your Page_Load or
Button_Click or whereever). Connections are pooled so in a miltiuser
environment like ASP.NET you'll have good chances of reusing open
connections that have been put back into the pool.
Also, it helps to make sure that you never have any idle connections. If
you open the connection in Page_Load, say, and close it in Unload... well,
there are cycles where the connection is doing nothing, but it's allocated
and owned by your page an unusable to anyone else. So putting it back in
the pool ASAP let others use it and you end up using fewer connections at
the same time.

Lastly, opening late and closing early makes for less buggy code and less
chances for a leak of the connection.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

I'm overriding OnUload in my pages. I've put the Connection.Close in
the
method.
But I have noticed that the method is run twice if I do a
Response.Redirect
in the page.
Do some one know why?
cheers,
mortb


Nov 19 '05 #4
> Or better still implement your connection management in a seperate layer
that closes the connection after the command is executed and have nodb
management code in your Page_Load or Button_Click events :)


I think OO is dead. The new thing is code in the UI!
Nov 19 '05 #5
> I think OO is dead.

You're right. Clemens Szyperski wrote about this in 2002 in his "Component
Software - Beyond Object-Oriented Programming":

http://research.microsoft.com/~cszypers/

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #6

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

Similar topics

1
by: cb | last post by:
When a Session timeout occurs, I get a 403 - Forbidden. The address bar contains the path that I was intending to go to but couldn't because of the timeout. How can I redirect the page when a...
10
by: Manny | last post by:
I have a web form "Page1.asp" and it reads data from a database, does some calculations, and displays the records in pages. Works fine. I have a button that displays on the page, defined as...
3
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the...
2
by: Gianmaria I. | last post by:
Hi, that's my problem.. i hve a pege where users can uload a text file and leave an e-mail address.. when upload finished.. my server start working on this file.. and later sends he resultin file...
12
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
2
by: Ricardo Videira | last post by:
Hi to all. I'm having trouble with the following situation: I have a page where the user inserts some stuff and when he clicks on the submit button a popup window showing that info is launched...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
5
by: Lupus | last post by:
Hi there! I have some strange behavior in a ASP VB.NET application. I've used response.redirect many times in different pages, and it works like a charm. However in a new page I'm making, the...
0
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.