为什么会报“文本内容中发现无效字符。处理资源”错呢,我没有做什么。
wwp_c 2010-02-02 05:18:22 我没有做什么,只是将文字内容以图片方式显示,居然报了这个错误。代码如下:
1)default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="default.aspx" alt="a"/>
</div>
</form>
</body>
</html>
2)default.aspx.cs:
page_load部分
if (!IsPostBack){
GetTextImage("网络技术有限公司");
}
private void GetTextImage(string m_texts)
{
Bitmap oBmp = new Bitmap(400,300);
Graphics oGraphics = Graphics.FromImage(oBmp);
SolidBrush oBrush = new SolidBrush(m_data.FontColor);
MemoryStream oMS = null;
oGraphics.Clear(Color.Yellow);
oGraphics.DrawString(m_texts.Trim(), new Font("黑体", 10, FontStyle.Italic),oBrush, 1, 1);
oMS = new MemoryStream();
oBmp.Save(oMS, ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "images/jpeg";
Response.BinaryWrite(oMS.ToArray());
oBrush.Dispose();
oGraphics.Dispose();
oBmp.Dispose();
Response.End();
}