0

On a website running under IIS 6.1 in Windows ASP.NET, I have a problem to refresh my image after doing a rotation.

I use the following c# functions :

img.RotateFlip(RotateFlipType.Rotate90FlipNone);
img.Save(output, System.Drawing.Imaging.ImageFormat.Jpeg);

The operation works well, when I open the image directly with the file system on the server, the image has completed the 90° rotation but on the site from the server, the image is not refreshed ... (the page is reloaded)

On the other hand, in localhost it works, the image is refreshed!

It is as if the image was blocking on the cache image...

Here's what I tried to force the reload of the image:

I tried to change the URL of the image by adding:

URL + "?no-cache=" + new DateTime().Date.Ticks;

I tried to put meta:

<meta http-equiv="Cache-control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />

I even tried with jQuery:

$(function () {
        $("img").each(function () {
            var d = new Date();
            $(this).attr("src", $(this).attr("src")+ "?v=" + d.getTime());
        });
    });

Nothing works, do you have another solution to offer me?

Thanks

A. Morel
  • 5,749
  • 41
  • 40
  • Have you tried all of the header tags listed here? http://stackoverflow.com/a/728685/3591108 – olingern Feb 16 '16 at 21:30
  • Thank you for the proposal, but it does not work. The problem may be with IIS because it works in localhost but not hosted with IIS ? – A. Morel Feb 17 '16 at 08:36

2 Answers2

0

Try the following code:

<br>
img.RotateFlip(RotateFlipType.Rotate90FlipNone);

'Set the content type<br>
response.contenttype="image/jpeg"

'send the bitmap to the outputstream<br>
img.save(response.outputstream, imageformat.jpeg)

'tidy up<br>
img.dispose() 
Inder
  • 3,350
  • 8
  • 22
  • 35
0

After Rotating the image try below code in View

$(".MainImg").attr("src", "@path" + ActualDocName + ".png?cache=none");

And for rotation try below in controller

if (System.IO.File.Exists(inpathpng))
 {
      System.Drawing.Image flipimage = System.Drawing.Image.FromFile(inpathpng);
      flipimage.RotateFlip(RotateFlipType.Rotate90FlipXY);
      flipimage.Save(inpathpng);
 }

Hope this might help others

Beena Gupta
  • 138
  • 10