asp.net+c# 图片读取显示问题!!!
这是读出图片的后台程序, 前台显示页只需要 <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();
}
}
不过遇到个很奇怪的问题,在文件系统下可以显示正常,在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();
}
}
...全文
相关推荐
C#在ListView中Subitem显示图片
这个程序实现了如何在ListView的列中显示图标或者图片,可以用于显示不同Item的状态。
ASP.NET二进制图片显示(C#)
是讲采用vs2005 + sqlServer2000。访问有名的Northwind数据库中的Employee表。其中Employee表中的photo中保存了员工的信息(image类型)。
压缩图片不失真,c# asp.net
随着数码相机的普及,很多照片都是用数码相机拍摄出来的。但是数码相机拍摄出来的照片体积很大,不变在网络上传输, 因此要对图片进行处理。本实例就是对图片进行无损压缩,并且使相片的清晰度为最佳状态。
C# asp.net MVC 图片上传 多图片
C# asp.net MVC 图片上传 多图片上传
asp.net c#代码 上传图片到服务器端和上传到数据库中 并产生缩略图显示在网页中
主要介绍了上传图片到数据库中和服务器端 并且介绍怎样显示图片的缩略图到网页中 资源中包含的已调试通过的源代码 本实验在vs2005 用c#语言编写


