473,769 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to keep one connection between two aspx page calls

Hi

I have asp.net programs. I used a very simple data transfer method by using
URLs

¡°First.aspx¡± contents a line to send data to the ¡°second.aspx¡± page, for
example: http://server/path/seond.apsx?data=mydata

There is a customer setting refresh rate in ¡°First.aspx¡± page.

So, if customer set refresh rate to 6 sec (mydata could be different each
time), there are more then 10 different calls (connections) to
¡°second.aspx¡± from the same ¡°first.aspx¡± page in one minute. This gave
me Error 403.9. (too many connections)

Is anyway I can keep the one connetions all the time between the two pages?

thanks
Nov 19 '05
11 1562
As I mentioned below, you are not disposing of your connection when you
are finished with it. If you wrap it in a using block, it will be
marked for garbage collection immediately after you close it.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #11
On 22 Aug 2005 08:53:14 -0700, "jasonkeste r" <ja*********@gm ail.com>
wrote:
As I mentioned below, you are not disposing of your connection when you
are finished with it. If you wrap it in a using block, it will be
marked for garbage collection immediately after you close it.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Not quite so. If your object uses a connection, simply disposing of it
is not the right way to close a connection. Instead, the connection
should be explicitly closed in the Dispose method of the IDisposable
interface:

public class MyWarrer : IDisposable
{
private SqlConnection _conn = null;
private bool _connIsMine = false;

// Constructor
public MyWrapper( SqlConnection conn )
{
if( conn != null )
{
this._conn = conn;
}
else
{
this._conn = new SqlConnection() ;
this._connIsMin e = true;
}
}

...

// IDisposable implementation - clean up
public void Dispose()
{
if( this._connIsMin e
&& this._conn != null )
{
this._conn.Clos e();
this._connIsMin e = false;
}
}
}

Then elsewhere you can use something like this:

using( MyWrapper wrapper = new MyWrapper( null ) )
{
// do you stuff
}

The above code allows you to use multiple wrappers and share the same
connection between them w/o risking leaving it open after the work is
done. The wrapper where the connection is created will be the one who
closes it as well. Normally, this the outermost wrapper in the calling
chain, assuming you are using wrappers from within each other.
Nov 19 '05 #12

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

Similar topics

1
4092
by: Jim Mitchell | last post by:
I store my connect string in the viewstate and open and close the SQL database in every function or sub-routine call. Is there a better method of opening the database when the ASPX page opens and cleanly closing it when the page exits? I guess the on open part is easy, but how do I know that the page closes so that I can be sure to close out the database connection? What happens if I do a server.transfer from any of the pages? Do I...
13
1900
by: Larry | last post by:
Hi I have asp.net programs. I used a very simple data transfer method by using URLs ¡°First.aspx¡± contents a line to send data to the ¡°second.aspx¡± page, for
7
2943
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have some insight about. 1) It takes 20 sec or so to open a tcp socket from the client to the server. It just sits in the TcpClient.conect waiting for something. When I run the same control from a windows application it connects right away and works...
4
4150
by: Nathaniel Sherman | last post by:
Alright, folks, here's the deal... I'm working on migrating a classic ASP website to an ASP.NET codebase. At the heart of the site is a MySQL database. To make sure an "in-process" program doesn't screw up the live site, I run a local IIS webserver on my XP Pro (AMD XP 2500+, 512MB DDR RAM) machine, which resides behind an XP ICS gateway on my LAN. I also have a MySQL server set up locally for development purposes.
35
11421
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing Then CType(cn, IDisposable).Dispose() End If I have to admit, I'm not sure what happens here. Will someone explain this line of code (the middle one, not the if statement LOL) to me please?
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.