读书人

IE8 不认识输出流?context.Response.

发布时间: 2012-10-16 09:57:37 作者: rapoo

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;        }    }}


[解决办法]
找到错就好~~~
[解决办法]
探讨

找到错就好~~~

读书人网 >asp.net

热点推荐