2010-01-19 59 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