用ashx生成图片页面,无法显示,,,,,大神求解,我发第二个求助贴了
用ashx生成图片页面,但无法显示....浏览器提示无法显示 XML 页。
我的代码如下:
<%@ 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; } }}