用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;
}
}}
帮忙分析下,感激不尽啊 我初学啊
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;
}
}}
帮忙分析下,感激不尽啊 我初学啊
无法显示 XML 页。
无法查看使用 样式表的 XML 输入。请更正错误然后单击 刷新 按钮,或稍后重试。
--------------------------------------------------------------------------------文本内容中发现无效字符。处理资源 'http://localhost:40305/WebSite7/handler/message.ashx' 时出错。
命名规范点