簡體   English   中英

ASP.NET網站(IIS 7.5,Win7)中的自定義HttpHandler出現錯誤500

[英]Error 500 with custom HttpHandler in ASP.NET website (IIS 7.5, Win7)

我正在嘗試在示例Web應用程序中使用自定義HttpHandler。 我遇到了很多問題,但最終陷入了錯誤500。應用程序池以經典ASP.NET 2.0模式運行。 服務器是IIS 7.5,操作系統是Win 7 Pro。

這是我的處理程序的代碼:

public class SampleHandler : IHttpHandler
{
    public SampleHandler()
    {

    }

    public bool IsReusable 
    {
        get 
        {
            return true;
        }
    }

    public void ProcessRequest(HttpContext context) 
    {
        context.Response.Clear();
        context.Response.ContentType = "text/html";
        context.Response.Write("This is a sample content.");
        context.Response.Expires = 0;
        context.Response.End();
    }
}

這是一個web.config文件的內容:

<?xml version="1.0"?>

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.shc" type="SampleHandler"/>
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers>
      <add resourceType="Unspecified" verb="*" path="*.shc" name="SampleHandler" type="SampleHandler" modules="IsapiModule" scriptProcessor="c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll\aspnet_isapi.dll"/>
    </handlers>
  </system.webServer>
</configuration>

這是錯誤屏幕截圖的鏈接: http : //bit.ly/cmPk4i

有人可以告訴我我做錯了什么嗎? 提前致謝!

嘗試設置

<validation validateIntegratedModeConfiguration="false" />

<system.webServer>

我有500個錯誤,此問題已解決。

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
        <add .... />
    </handlers>
</system.webServer>

從“您可以嘗試的東西”列表中,您是否安裝了.Net可擴展性功能?

您還可以在應用程序上啟用失敗請求日志記錄功能,該功能提供有關請求處理的詳細信息。

至少好消息是,您注冊的處理程序被識別為要執行的處理程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM