Efitap
October 19th, 2008, 06:25 AM
Hello, experts!
I need help with a scenario:
I have a photography server that builds image paths dynamically to clients for downloading. This works as intended except for the following:
Each time a viewer wants an image preview, a new session is created on the server, terminating only one hour later. When there is lots of traffic, the sessions accumulate, and end up overwhelming the server.
I initially loaded the image uri more or less like this:
-- snip --
string xmlSourceUrl = GetImageUrl( );
XElement sourceRoot = XElement.Load( xmlSourceUrl );
string result = ( from file in sourceRoot.Descendants( "PreviewUrl" ) select sourceRoot.Value ).Single< string >( );
-- snip --
Which is bad. It looks like linq for Xml supports loading xml directly over http, but there is no way to tell it afterwards that the session should end immediately.
I tried using a WebClient object, but I cannot find a "Terminate", "Close", "Abandon" or any other function to indicate that I would like the session to end immediately after reading the stream.
Here is how it looks:
// Create a webclient object to read with
WebClient wc = new WebClient( );
// prepare a reader object
TextReader reader = new StreamReader( wc.OpenRead( completeUrl ) );
/// To XElement using the reader
XElement result = XElement.Load( reader , LoadOptions.None );
// Close the reader
reader.Close( );
// client goes out of scope here - does session terminate?
return result;
Can anyone help please?
I need help with a scenario:
I have a photography server that builds image paths dynamically to clients for downloading. This works as intended except for the following:
Each time a viewer wants an image preview, a new session is created on the server, terminating only one hour later. When there is lots of traffic, the sessions accumulate, and end up overwhelming the server.
I initially loaded the image uri more or less like this:
-- snip --
string xmlSourceUrl = GetImageUrl( );
XElement sourceRoot = XElement.Load( xmlSourceUrl );
string result = ( from file in sourceRoot.Descendants( "PreviewUrl" ) select sourceRoot.Value ).Single< string >( );
-- snip --
Which is bad. It looks like linq for Xml supports loading xml directly over http, but there is no way to tell it afterwards that the session should end immediately.
I tried using a WebClient object, but I cannot find a "Terminate", "Close", "Abandon" or any other function to indicate that I would like the session to end immediately after reading the stream.
Here is how it looks:
// Create a webclient object to read with
WebClient wc = new WebClient( );
// prepare a reader object
TextReader reader = new StreamReader( wc.OpenRead( completeUrl ) );
/// To XElement using the reader
XElement result = XElement.Load( reader , LoadOptions.None );
// Close the reader
reader.Close( );
// client goes out of scope here - does session terminate?
return result;
Can anyone help please?