How to rotate an image in .NET?

I have an asp.net 2010 project. I am writing jpg to the file system. Then I show it in the Image control. Then I use this code when I click the button so that the user can rotate it 90 degrees.

string path = Server.MapPath(Image1.ImageUrl) ;

// creating image from the image url
System.Drawing.Image i = System.Drawing.Image.FromFile(path);

// rotate Image 90' Degree
i.RotateFlip(RotateFlipType.Rotate90FlipXY);

// save it to its actual path
i.Save(path);

// release Image File
i.Dispose();

It rotates (I can observe how this happens in Windows Explorer). But when I run the application again and it grabs the file from its path, it still displays it in its original form.

+3
source share
2 answers

Try adding a dummy query to the end of the image, for example, "image1.jpv? V = 1". This helps prevent caching of things like Javascript files, and can do the same for you.

0
source

, . Alison - . - . "" , . , , , - . , , .

- ( XML ) , "" . . , "" , . .

0

Source: https://habr.com/ru/post/1791297/


All Articles