简体   繁体   中英

ASP.NET HTTP Handler Unrecognized Request

I have ASP.NET handler. But when I try to call it it says :

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable .

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>

I try to make request like this, but with unsuccess:

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

Looking at our code which works, some ideas:

  • Try adding the handler under system.webServer instead of system.web
  • Try adding the attribute preCondition="integratedMode"
  • Try specifying a name attribute

I think as you have written your path as

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

Instead of this try

 http://localhost:60223/vishal.nayan

This is because your path element contain vishal.nayan only.

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

if you still have issue then tell me does you have hosted on IIS or IIS express ?

If you have configured in IIS ( IIS 7 or 7.5 later then you have to configure in

   <system.webServer>
    <handlers>
      <add name="test" verb="*" path="vishal.nayan" type="SimpleHTTPHanlder.SimpleHandler"/>
    </handlers>
    ...... other configuration
   </system.webServer>
http://localhost:60223/SimpleHTTPHanlder/vishal.nayan

is it a copy/paste with a typo ? ( Hanlder )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM