ASP.NET HTTP处理程序无法识别的请求

时间:2014-11-28 09:16:15

标签: c# asp.net handler httphandler

我有ASP.NET处理程序。但当我试着打电话时,它说:

您要查找的资源已被删除,名称已更改或暂时不可用

namespace SimpleHTTPHanlder
{
    public class SimpleHandler : IHttpHandler
    {
        #region IHttpHandler Members

        bool IHttpHandler.IsReusable
        {
            get { return true; }
        }
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            HttpResponse response = context.Response;
            response.Write("<html><body><h1>Wow.. We created our first handler");
            response.Write("</h1></body></html>");
        }
        #endregion
    }
}




<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0" />
      <httpHandlers>
        <add verb="*" path="vishal.nayan" type="SimpleHTTPHanlder.SimpleHandler"/>
      </httpHandlers>
    </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
</configuration>

我尝试提出这样的请求,但是失败了:

http://localhost:60223/SimpleHTTPHanlder/vishal.nayan

3 个答案:

答案 0 :(得分:0)

查看我们的代码,有些想法:

  • 尝试在system.webServer下添加处理程序,而不是system.web
  • 尝试添加属性preCondition="integratedMode"
  • 尝试指定name属性

答案 1 :(得分:0)

我认为你已经把你的道路写成了

  http://localhost:60223/SimpleHTTPHanlder/vishal.nayan.

而不是尝试

 http://localhost:60223/vishal.nayan

这是因为你的路径元素只包含vishal.nayan。

 <httpHandlers>
        <add verb="*" path="vishal.nayan" type="SimpleHTTPHanlder.SimpleHandler"/>
      </httpHandlers>

如果您仍有问题,请告诉我您是否已在IIS或IIS Express上托管?

如果您已在IIS(IIS 7或7.5之后)中进行配置,则必须在

中进行配置
   <system.webServer>
    <handlers>
      <add name="test" verb="*" path="vishal.nayan" type="SimpleHTTPHanlder.SimpleHandler"/>
    </handlers>
    ...... other configuration
   </system.webServer>

答案 2 :(得分:-1)

http://localhost:60223/SimpleHTTPHanlder/vishal.nayan

是一个拼写错误的复制/粘贴吗? (处理程序)