0

Well, I know it's IIS which is supposed to invoke it. Anyway; I have a Sharepoint solution which is supposed to return a special string when files with particular extensions are clicked on document libraries.

In the corresponding web.config file I have following to run this HTTP Handler:

<system.webServer>
   <handlers>
       ...
       <add name="MyFileHandler" path="*.bar" verb="*" type="Foo.Example.MyHandler, Foo.Example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b53a24010893ac2" resourceType="File" />
       ...
    </handlers>
</system.webServer>

And the HttpHandler class is something like this:

namespace Foo.Example
{
    public class MyHandler : IHttpHandler
        {   
            public MyHandler(){} //For breakpoint

            public void ProcessRequest(HttpContext context)
            {
                //Do stuff and write to response.
            }

            public bool IsReusable
            {
                get { return false; }
            }
       }
}

When I try to open a file with '.bar' extension on Sharepoint, it returns 404. What I do in ProcessRequest is not relevant because when I debug the handler, I can see that the handler's constructor is invoked but not the 'ProcessRequest'. Besides the debugger I have also put debug lines(File.AppendAll), again only the constructor gets invoked according to the debug output.

IIS 7.5.7600

Sharepoint 2010 Foundation

Natan
  • 2,816
  • 20
  • 37

2 Answers2

1

Turns out

resourceType="File"

on handler tag in web.config was the problem. Either remove it or set it as "Unspecified".

That is already mentioned here which, unfortunately, I failed to spot before.

Community
  • 1
  • 1
Natan
  • 2,816
  • 20
  • 37
0

The only thing I can think of is to try moving your handler to be really the first one.

Otherwise it could be better to actually integrate with SharePoint instead of trying to override its behavior. In this case you probably should post separate question for what you want to achieve.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179