Custom Http Handlers IIS7 and ASP.NET

We have some HTTP handlers specified in our web.config. When we were running this site via a Web Site Project, all worked fine. But for some reason, after porting this over to a WAP project and pointing to the .NET 3.5 framework, the handlers are not working when I bring up the site in IIS 7 on our dev box. Do I need to do something special in IIS7 other than the specified custom handlers that already exist in my web.config?

When I look at the Handler Mappings section in IIS 7 for our site, I do see the 3 handlers listed with our custom extension. So it looks like it’s picking up our handlers specified in our web.config. But I know that the handlers that were working in a non-wap website are not working in this WAP project and I don’t know why.

For example, when one of our handlers tries to kick in when referenced I get:

Server Error in ‘/’ Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'jaxHandler'.

Source Error:

Line 1:  
Line 2:  
Line 3:  using System;


Source File: /jaxHandler.ashx    Line: 1

Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074 

furthermore, when I try to click on a hyperlink on our site that has .customextension on it the handler doesn’t seem to pick it up.

So when I click on the hyperlink, I get:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error InformationModule IIS Web Core 
Notification MapRequestHandler 
Handler StaticFile 
Error Code 0x80070002 
Requested URL http://sss:80/somename.prod
Physical Path C:wwwssssomename.prod 
Logon Method Anonymous 
Logon User Anonymous 

(I have replaced the real text with ‘somename’ and our company name with ‘sss’) in the case above for privacy.

If I look in the Http Handlers section in IIS7, I do see that *.prod is registered. And here is how we have it set up in our web.config under the custom section:

<add name="sss" path="*.prod" verb="*" modules="IsapiModule" scriptProcessor="C:WindowsMicrosoft.NETFrameworkv2.0.50727aspnet_isapi.dll" resourceType="Unspecified" preCondition="bitness32"/>

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

For ASP.NET applications running on IIS7, HttpHandlers should be mapped in the <system.webServer> section of your web.config. In IIS6, they were mapped in the <system.web> section.

<system.webServer>
    <handlers>
        <add name="HandlerName" 
             path="HandlerPath" verb="*" type="Handler.Type"
             resourceType="Unspecified" />
    </handlers>
</system.webServer>

Method 2

What you need to do is build your code.

You need to copy all the C# code out into a .ashx.cs file. In fact, I recommend you create a new .ashx and copy the C# code into its .ashx.cs file.

Web sites build dynamically. Web Application Projects, like every other similar project type in Visual Studio, need to have code in source files, and to have that code build into an assembly.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x