2010-01-19 57 views
1

我加载形象从我的数据库中的临时文件,但我的IIS不能看到这个文件,所以我需要将它添加到我的ISS莫名其妙。 我在这里看到的一些方法Link 所以问题是如何使与ImageHandler.dll 工作,我需要为它创建新的DLL应用程序,然后添加到我的web应用程序的仓?ASP.NET [添加图片到ISS - DLL?]

+0

如何使用Handler.ashx:P – Cynede 2010-01-20 06:22:28

回答

3

可以使用generic handlers它。下面是一个示例:

<%@ WebHandler Language="C#" Class="Handler" %> 

using System; 
using System.IO; 
using System.Web; 
using Deimand.Business; 
using System.Configuration; 

public class Handler : IHttpHandler 
{ 
    public bool IsReusable 
    { get{ return false; } } 

    public void ProcessRequest(HttpContext context) 
    { 
     context.Response.ContentType = "image/jpeg"; 
     if (context.Request.QueryString["imageId"] != null) 
     { 
      byte[] imageContent = GetImageFromDataBase(context.Request.QueryString["imageId"]); 
      context.Response.OutputStream.Write(imageContent, 0, imageContent.Length); 
     } 
    } 
} 
+0

非常感谢 – Cynede 2010-01-19 08:24:45