asp.net+c# 图片读取显示问题!!!

ht89472112 ht89472112 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是读出图片的后台程序, 前台显示页只需要 <img src="imgshow.aspx?imgNo=1"> 即可显示。
不过遇到个很奇怪的问题,在文件系统下可以显示正常,在IIS下不行!! 是属于什么问题,帮忙看看,谢谢!~~~

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class _imgshow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int NNo = Convert.ToInt32(Request.QueryString["imgNo"]);
SqlDataReader read;
SqlConnection conn = new SqlConnection("server=localhost; database=hkDatabase; User=sa; Password=123");
SqlCommand comm = new SqlCommand("SELECT NImg,NFileType,NFileSize FROM News WHERE NNo=" + NNo, conn);
comm.Connection = conn;
comm.Connection.Open();
read = comm.ExecuteReader();
read.Read();
Response.ContentType = Convert.ToString(read["NFileType"]);
Response.OutputStream.Write((byte[])read["NImg"], 0, Convert.ToInt32(read["NFileSize"]));
Response.End();
read.Close();
conn.Close();
read.Dispose();
conn.Dispose();
comm.Dispose();
}
}
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
ht89472112
.NET社区 62,274 成员 668,968 内容