Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpHandler not working in ASP.NET MVC3 web application

I've recently taken an existing ASP.NET 3.5 web forms application that was upgraded to .NET 4 last year (and has been running fine) and configured it to also run ASP.NET MVC3 following Scott Hanselman's blog post: Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications. It works well and I've successfully begun to introduce views based on Razor and the existing aspx pages continue to work.

The one thing that has stopped working, however, is a custom HttpHandler (our load balancer hits a specific address to ensure the application is available - the handler is for that address). The web.config has always declared the handler in the system.web section like this:

<httpHandlers>
  <add verb="*" path="system/heartbeat.aspx"
    type="My.Monitor.HttpHandlers.LoadBalancerHandler, My.Monitor"/>
</httpHandlers>

Now we're testing post-MVC3 and I'm getting an exception that reads:

The controller for path '/system/heartbeat.aspx' was not found or does not implement IController.

I have defined a RegisterRoutes method in my Global.asax and that method is called from the Application_Start. Within RegisterRoutes I've got the IgnoreRoute declarations from Hanselman's blog:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

which I thought was to prevent the Routing system from taking anything with an extension of .aspx.

I can reproduce the issue in VS2010 as I debug, and the deployment environment is running IIS 6.

What can I do to prevent the Routing system from trying to handle that address so the custom handler can do it's thing? Any help is appreciated.

like image 531
BigPigVT Avatar asked Dec 28 '22 22:12

BigPigVT


1 Answers

Try like this:

routes.IgnoreRoute("system/heartbeat.aspx");
like image 85
Darin Dimitrov Avatar answered Jan 15 '23 00:01

Darin Dimitrov