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

用ashx生成图片页面,无法显示,,,,,大神求解,我发第二个求助贴了
用ashx生成图片页面,但无法显示....浏览器提示无法显示 XML 页。 

我的代码如下:

C# code
<%@ WebHandler Language="C#" Class="访问者信息" %>

using System;
using System.Web;
public class 访问者信息 : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/JPEG";
        using(System.Drawing.Bitmap bitmap=new System.Drawing.Bitmap(200,200))
        {
            using(System.Drawing.Graphics g=System.Drawing.Graphics.FromImage(bitmap))
            {
                g.DrawString("ip:" + context.Request.UserHostAddress, new System.Drawing.Font("宋体", 20), System.Drawing.Brushes.Red, 0, 0);
                g.DrawString("操作系统" + context.Request.Browser.Platform, new System.Drawing.Font("宋体", 20), System.Drawing.Brushes.Red, 0, 30);
                g.DrawString("浏览器:" + context.Request.Browser.Version, new System.Drawing.Font("宋体", 20), System.Drawing.Brushes.Red, 0, 60);
               
            }
            bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}



帮忙分析下,感激不尽啊 我初学啊

------解决方案--------------------
context.Response.ContentType = "image/jpeg";
------解决方案--------------------
我也觉得是ContentType 的问题
------解决方案--------------------
context.Response.ContentType = "image/jpeg";

public class 访问者信息,
命名规范点