日期:2014-05-17  浏览次数:20420 次

IE8 不认识输出流?!context.Response.OutputStream??
我写了一个给图片加水印的ashx 在其他浏览器里都跑的不错 就是在ie8里说什么:

无法显示 XML 页。 
使用 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。 


--------------------------------------------

文本内容中发现无效字符。处理资源 'http://localhost:5671/Demos01/ShuiYin.ashx' 时出错。 

我明明把 context.Response.ContentType = "image/jpg"; 设成 图片格式了啊!!

C# code

<%@ WebHandler Language="C#" Class="ShuiYin" %>

using System;
using System.Web;
using System.Drawing;
public class ShuiYin : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "image/jpg";
        
        string strimgpath = context.Server.MapPath(@"UpLoad\1.jpg");
        using (Image img = Bitmap.FromFile(strimgpath))
        {
            using (Graphics g = Graphics.FromImage(img))
            {
                g.DrawString("水印", new Font("宋体", 16), Brushes.Black, 50, 100);
                img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }  
     
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}




------解决方案--------------------
找到错就好~~~
------解决方案--------------------
探讨

找到错就好~~~