【问题标题】:ASP.NET [Add image to ISS - dll ?]ASP.NET [将图像添加到 ISS - dll ?]
【发布时间】:2010-01-19 07:30:50
【问题描述】:

我正在将图像从我的数据库加载到临时文件,但我的 IIS 看不到这个文件,所以我需要以某种方式将它添加到我的 ISS。 我在这里看到了某种方式Link 所以问题是如何制作和使用 ImageHandler.dll 我需要为其创建新的 dll 应用程序,然后添加到我的网络应用程序的 bin 中吗?

【问题讨论】:

    标签: asp.net iis


    【解决方案1】:

    您可以使用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);
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2011-07-21
      • 1970-01-01
      • 2014-09-05
      • 2014-02-20
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      相关资源
      最近更新 更多