加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET处理程序未在IIS7上运行

发布时间:2020-12-16 03:20:02 所属栏目:asp.Net 来源:网络整理
导读:我写了一个简单的处理程序: public class ImageHandler : IHttpHandler,IRequiresSessionState{ public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { byte[] imgData = context.Session["Data"] as byte[]
我写了一个简单的处理程序:

public class ImageHandler : IHttpHandler,IRequiresSessionState
{
    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
        byte[] imgData = context.Session["Data"] as byte[];

        if (imgData != null)
        {
            context.Response.CacheControl = "no-cache";
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.ContentType = "image/png";

            context.Response.BinaryWrite(imgData);
            context.Response.Flush();
        }
    }
}

并设置web.config:

<system.web>
    <httpHandlers>
      <add verb="GET" path="image.png" type="TestWeb.Handlers.ImageHandler,TestWeb" />
    </httpHandlers>
  </system.web>

  <system.webServer>
    <handlers>
      <add name="Image" verb="GET" path="image.png" type="TestWeb.Handlers.ImageHandler,TestWeb" />
    </handlers>
  </system.webServer>

>如果我运行代码允许VS启动新的IIS服务并打开一个新选项卡,它将到达处理程序的断点.
>如果我设置不打开页面.等待来自外部应用程序的请求,它永远不会到达处理程序.

它不仅仅是断点,当我运行在IIS上配置的网站时,处理程序中没有代码执行.只有从VS开始才有效.

配置IIS7时我错过了什么?

解决方法

我不得不将应用程序池切换到集成模式,它使用经典.

我不得不从< system.web>中删除处理程序配置.因为它给了我500.23的错误.

HTTP Error 500.23 – Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读