开发者

Why do I get HTTP 404 when there's no .asmx extension?

I'm trying to write an HTTP GET handler. The path should start with http://site/processTask and have a set of URL-encoded parameters. I have the following in my web.c开发者_运维知识库onfig

<httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    <add verb="GET" path="processTask*" type="MyHandler.ProcessTaskHandler, MyHandler"/>
</httpHandlers>

now when I type the URL http://mysite/processTask in browser I get HTTP 404 but if I change the add verb line to the following one:

<add verb="GET" path="processTask.asmx*" type="MyHandler.ProcessTaskHandler, MyHandler"/>

and type http://mysite/ProcessTask.asmx in browser the handler is run and I get the response from the handler.

What's the problem? Why is the handler run only when the path contains .asmx? How do I change web.config so that .asmx is not required?


When a path is just /processTask (no extension) IIS can not understand first of all that it has to pass the request to ASP.NET especially on IIS 5.1, and the file is not being processed by ASP.NET but just served from disk (and there's no such file, hence HTTP 404).

To be able to do that you need to set IIS to process all files with ASP.NET

On IIS 5.1, right click on the root, open Web Site Properties | Home Directory | Configuration, and there copy/paste settings from *.aspx (or any other extension that is already handled by ASP.NET) to a new extension as .* and uncheck "Verify file exists" checkbox there. Here's a step-by-step guide for a similar problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜