我有一个 asp.net 2010 项目。我将 jpg 写入文件系统。然后我将它显示在图像控件中。然后我在单击按钮时使用此代码以允许用户将其旋转 90 度。
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();
它确实会旋转(实际上我可以在 Windows 资源管理器中看到发生的情况)。但是,当我再次运行该应用程序并从其路径中抓取文件时,它仍以其原始形式显示。
最佳答案
尝试在图像末尾添加一个虚拟查询字符串,例如“image1.jpv?v=1”。这可以防止缓存诸如 Javascript 文件之类的东西,它可能对你也有同样的作用。
关于asp.net - 如何在 .NET 中旋转图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4961918/