【问题标题】:HttpHandler receiving 404 and 500 errorsHttpHandler 收到 404 和 500 错误
【发布时间】:2014-04-25 17:03:00
【问题描述】:

我在 WindowsServer 2008 R2 和 IIS 6.1 sp1 上运行网站

我创建了一个空的 ASP.NET 4.0 Web 应用程序,并向其中添加了一个 http 处理程序。处理程序的工作是根据查询字符串中传递的 tokenid(来自联合单点登录提供程序)将传入呼叫重定向到其他站点。

为了测试连接,我只是将令牌解析为字典并将信息写入 context.Response。

处理程序在我的机器上运行,但是当我部署它时,我收到 500 和 403 错误。 使应用程序池 ASP.NET 4.0 集成时出现 500 错误,使应用程序池 ASP.NET 4.0 经典时出现 404 错误

如果我将 test.htm 添加到目录中,我可以访问 test.htm 并查看其内容,但我希望看到处理程序的输出,所以它让我认为它找不到处理程序。

这里是 web.config,后面是代码

   <configuration>
       <system.web>
          <compilation debug="true" targetFramework="4.0" />

          <httpHandlers>
             <add verb="*" path="*"
                type="RedirectSite.RedirectHttpHandler, RedirectSite, Version=1.0.0.0, Culture=neutral" />
          </httpHandlers>        
       </system.web>        
    <configuration>

        public class RedirectHttpHandler : IHttpHandler
            {

                public RedirectHttpHandler()
                { }

                public void ProcessRequest(HttpContext context)
                {

                    // check for tokenid in querystring
                    string tokenid = context.Request.Params["tokenid"];
                    string agentid = context.Request.Params["agentid"];

                    Dictionary<string,string> tokenItems = TokenParser.Parse(tokenid, agentid);

                    context.Response.Clear();

                    context.Response.Write("<b>Token Information</b><br/><br/>");

                    foreach (KeyValuePair<string, string> item  in tokenItems)
                    {
                        context.Response.Write(String.Format("{0} : {1}<br/>",item.Key,item.Value));
                    }

               }
                public bool IsReusable { get; private set; }
            }

【问题讨论】:

  • 只是天空中的一枪,但是,你的组合应该是StrongNamed/Signed吗?

标签: c# asp.net httphandler


【解决方案1】:

原来网站的 ISAPI/CGI 设置阻止了 4.0 - 一旦启用,网站就可以工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-24
    • 2017-05-03
    • 2015-05-18
    • 2016-07-29
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    相关资源
    最近更新 更多