My RouteConfig.cs
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*allaspx}", new {allaspx = @".*\.aspx(/.*)?"});
routes.IgnoreRoute("{*allasmx}", new { allasmx = @".*\.asmx(/.*)?" });
routes.IgnoreRoute("{*allsvc}", new { allsvc= @".*\.svc(/.*)?" });
routes.IgnoreRoute("{*allFileAttachments}", new { allattachment = @".*\file.attachment(/.*)?" });
...
...
...
}
}
Web.config
<configuration>
....
<system.web>
<httpHandlers>
<add path="*.attachment" verb="*" type="MyType, Namespace" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="attachmentHandler" />
<add name="attachmentHandler" verb="*" path="*.attachment" type="myType, namespace" preCondition="integratedMode" />
</handlers>
...
</system.webServer>
...
</configuration>
When I try accessing the following URL, it still tries to find a controller and fails with 404
This solved the issue.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="attachmentHandler" verb="*"
path="*.attachment"
type="myType, namespace"
resourceType="Unspecified" />
</handlers>
...
</system.webServer>
Reference MSDN - To register an HTTP handler for IIS 7.0 running in Integrated Mode