【问题标题】:Using HttpHandler (ashx) to serve images使用 HttpHandler (ashx) 提供图像
【发布时间】:2016-06-26 21:45:05
【问题描述】:

我正在尝试实现一个 httphandler 来提供图像。我看过很多例子,这个过程似乎很简单。但是,似乎我的图像标签

<img src="ImageHandler.ashx?picture=moon.jpg" />

坚持将对处理程序的调用解释为直接 URL。 ImageHandler.ashx 位于 App_Code 文件夹中。我认为问题在于注册处理程序。这是我当前的 web.config 条目(我已经尝试了很多,包括 *.jpg 作为路径。):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="ImageHandler" path="*.ashx" verb="*" type="ImageHandler" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" />
        resourceType="Unspecified" />
    </handlers>
  </system.webServer>
</configuration>

我错过了什么?! 谢谢!

【问题讨论】:

    标签: image httphandler


    【解决方案1】:

    Visual Studio 决定 ashx 文件需要是两个文件。我知道那是怎么回事。但是,我不知道(直到我尝试将文件复制到 App_Code 文件夹中和从中复制出来)是在应用程序根目录中拥有 ashx 文件,而在 App_Code 文件夹中拥有 ashx.vb 文件会使处理程序工作 - 没有需要在 web.config 文件中注册它。从来没有见过这样的东西。

    【讨论】:

      猜你喜欢
      • 2010-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多