Note that there are some explanatory texts on larger screens.

plurals
  1. POImage caching issue by using files in ASP.NET
    primarykey
    data
    text
    <p>I am facing a problem with Image caching by using files in ASP.NET. My detailed solution is:</p> <ul> <li><p>For 1st request: I check the image file not exists and write the image file into hard disk. After that returns the url of the file to the browser</p></li> <li><p>For later requests: the function just returns the url of the file to the browser</p></li> </ul> <p>My problem is: sometimes with 1st requests, the browser can not get the image data from the url and cause the 404 - File Not Found error. I think it might because of the file is written but not ready for retrieving from browsers, but in the code I am using both "using statement" and "Dispose method" for bitmap &amp; graphic objects to ensure everything are ready for accessing from browsers.</p> <p>In more details, I am using the similar solution as in NopCommerce:</p> <pre><code>lock (s_lock) { ........... using (var stream = new MemoryStream(LoadPictureBinary(picture))) { using(var b = new Bitmap(stream)){ using(var newBitMap = new Bitmap(newSize.Width, newSize.Height)){ ....................... newBitMap.Save( Path.Combine(this.LocalThumbImagePath, localFilename), ici, ep); } } } } // end lock return url; </code></pre> <p>More information: you can check the full code at <a href="http://nopcommerce.codeplex.com/SourceControl/changeset/view/9125b9a7fafe#src%2fLibraries%2fNop.Services%2fMedia%2fPictureService.cs" rel="nofollow">http://nopcommerce.codeplex.com/SourceControl/changeset/view/9125b9a7fafe#src%2fLibraries%2fNop.Services%2fMedia%2fPictureService.cs</a> (please search the GetPictureUrl() function)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload