I’m using a static method in a class, this static method contains a connection string. I use this static method in all other methods to open a database connection and I dispose the connection within this method.
After I deploy this application in IIS, when two users login to the application on two different machines and access the same page containing the same menu at a time, I’m getting the error as:
Cannot perform this operation for disposed connection.
Why is this happening?
I suspect you’ve actually got a static variable storing the connection, rather than having a connection per request. You shouldn’t do that: each request should open the connection as it needs to, and dispose of the connection at the end… but you shouldn’t be storing the connection in a field where other requests may use it.
Of course, if you could actually show us some sample code, it would be rather easier to diagnose…