【发布时间】:2010-01-19 07:30:50
【问题描述】:
我正在将图像从我的数据库加载到临时文件,但我的 IIS 看不到这个文件,所以我需要以某种方式将它添加到我的 ISS。 我在这里看到了某种方式Link 所以问题是如何制作和使用 ImageHandler.dll 我需要为其创建新的 dll 应用程序,然后添加到我的网络应用程序的 bin 中吗?
【问题讨论】:
我正在将图像从我的数据库加载到临时文件,但我的 IIS 看不到这个文件,所以我需要以某种方式将它添加到我的 ISS。 我在这里看到了某种方式Link 所以问题是如何制作和使用 ImageHandler.dll 我需要为其创建新的 dll 应用程序,然后添加到我的网络应用程序的 bin 中吗?
【问题讨论】:
您可以使用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);
}
}
}
【讨论】: