I know this question is pretty old, but I found a solution that seems to work for me.
My solution calls the ASHX handler, which then returns the image; on average, this service is called between 10-14 times to load a page on a specific page.
I am using the ODP.NET Oracle.DataAccess.Client V4.112.3.60 namespace for 64 bits.
I have all the code in using operators (obfuscation here):
using (OracleConnection conn = new OracleConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["####"].ConnectionString)) { using (OracleCommand cmd = new OracleCommand(query, conn)) { OracleParameter p = new OracleParameter("####", OracleDbType.Varchar2, 10); p.Direction = ParameterDirection.Input; p.Value = val; cmd.Parameters.Add(p); conn.Open(); using(OracleDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { if (reader.HasRows) { while (reader.Read()) { OracleBlob lob = reader.GetOracleBlob(0); //OracleLob lob = reader.GetOracleLob(0); srcImage = new Bitmap(lob); } newImage = resizeImage(srcImage, new Size(120, 150)); newImage.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } else { srcImage = new Bitmap("Images/none.jpg"); newImage = resizeImage(srcImage, new Size(120, 150)); newImage.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); ProcessError(ref context, 500); } } p.Dispose(); } }
I have tried many things:
- Verify that other connections open simultaneously
- Re-wrote the SQL data source control so I have more control over the connections
- Using System.Data.OracleClient)
But when it came to passing the code, I found that sometimes the code did not reach the end of the used block, and the next request would come to the handler before it could reach the end (I guess something to do with the maximum handler requests?) , this led to some sessions remaining open in V $ SESSION, which I had to close manually.
I came across this bit of code:
OracleConnection.ClearAllPools();
And I tried to start it, although the sessions will remain open by the handler, at least they will be closed by this code, currently it starts at the end of the use block for OracleConnection (therefore, every time the service clears the pools, which hopes that the handler will be able to execute it is far!).
So using the ClearAllPools method seems to work, but I know this is not an ideal solution.