我开发了一个简单的ashx服务,可以从远处的系统中拍摄图像,并将它们呈现在.net应用程序中。在开发过程中,一切都工作正常,应该与生产环境相同,因此这似乎是一个配置错误。
实现图像的页面也会在日志窗口中返回此消息
资源解释为图像但使用MIME类型text / html传输
生产中
开发中
此外,代码和web.config等在环境中是相同的。我甚至复制了整个开发树并在开发服务器上运行它,结果完全相同。
我的实现看起来像这样
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers accessPolicy="Read, Write, Script, Execute">
<remove name="SPImage" />
<add name="SPImage" verb="GET" path="SPImage.ashx" type="Web.Business.Handlers.SPImage, Web" />
</handlers>
</system.webServer>
和处理程序
namespace Web.Business.Handlers
{
public class SPImage : IHttpHandler
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
Guid imageGuid;
if (!Guid.TryParse(context.Request.QueryString["id"], out imageGuid))
// Get user
var user = aspnet_MembershipController.Read<aspnet_MembershipListModel>(context.User.Identity.Name);
// Get requested image
var image = GalleryListController.ReadImage<IGalleryPicture>(user.ID, imageGuid);
byte[] file = DownloadProcedureController.Download<byte[]>("gallerier", image.Webimage);
int width = 270;
int height = 180;
// Return image in scaled format
var stream = new MemoryStream();
var settings = new ResizeSettings(string.Format("width={0};height={1};format=jpg;quality={2};mode=crop", width, height, 100)) {};
// ...process the image
new ImageResizer.ImageJob(file, stream, settings).Build();
HttpResponse httpResponse = context.Response;
httpResponse.ContentType = "image/jpeg";
//httpResponse.CacheControl = "no-cache";
httpResponse.BufferOutput = false; //Stream the content to the client, no need to cache entire streams in memory...
httpResponse.BinaryWrite(stream.GetBuffer());
httpResponse.End();
}
}
}
有人认出这个吗?
由于
答案 0 :(得分:0)
ImageReziser中的错误是质量未正确设置。因此压缩的结果。 通过更新ImageRezising.net修复