I am writing IHttpHandler now. My environment is Windows 7 Enterprise, IIS 7 (appears). My handler works as an application in the default application pool, which works in integrated mode.
Currently, my ProcessRequest () handler method does only the following (just testing at this stage):
public void ProcessRequest(HttpContext context) { context.Response.StatusCode = 200; context.Response.ContentType = "text/html"; context.Response.Output.Write("file uploaded."); }
I add a handler via web.config as follows:
<configuration> <system.webServer> <handlers> <add name="HttpUpload" path="*" verb="*" type="HttpUpload, HttpUpload" resourceType="Unspecified"/> </handlers> </system.webServer> </configuration>
I use curl to check my handler. When I do the following:
curl http:
It works. However, when I try to execute PUT as follows:
curl --upload-file build.txt http:
It does not work with error 405, Method Not Allowed. I searched, while others on stackoverflow indicated that the WebDAVModule needs to be removed. I deleted this and it resolved the 405 error. However, now I get the 500.21 error. From an unsuccessful request tracking this, it says that the IIS Web Core module is generating error 500.21 because "The data is invalid." (8007000D). This problem seems similar to this post:
IIS 7, HttpHandler and HTTP Error 500.21
But what seems to fix for others, for example, running aspnet_regiis -i, did not affect me. I debugged my handler and it breaks the ProcessRequest () handler method when using GET, but it does not interrupt when using PUT, so I know that it is not even called. For some reason, this other main module is not making a call.
EDIT:
I ran the curl command against the same url that POST is doing and it worked. So GET and POST work against my HTTP handler, PUT does not. I also ran the same -upload-file curl command for the url in the same field that WebDAV supported, and that worked.
Thanks Nick