I use an Http handler to localize the javascript files used in my application: see Localize Text in JavaScript Files in ASP.NET
I want to use a handler, so I did the following:
1) Ignored routes using this code in Global.asax - I added the lines of code routes.IgnoreRoute("{resource}.js.axd/{*pathInfo}"); in the RegisterRoutes method so that it looks like this:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.js.axd/{*pathInfo}"); routes.MapRoute( "Default",
2) I added the line <add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" /> to my web.confing file in the Views folder so that it looks like this:
<system.web> <httpHandlers> <add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" /> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers>
And still, I get a page error message when I try to access the following URL:
http:
What am I doing wrong here?
<h / "> Progress: Okay, so I found the awkward mistake I made ... For some reason, I thought that when adding Handler for *.js.axd would find the file, but in fact it is not, because the file was named OrganizationalStructure.js without the .axd extension, so this is the cause of the 404 error, but now I get another error from the server and I need your help again.
Access to http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd this time caused another error: 404.17 The requested content looks like a script and will not be served by a static file handler.
Additional error information
Server Error in Application "CAMELOTSHIFTMANAGEMENT.COM" Internet Information Services 7.5 Error Summary HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. Detailed Error Information Module: "StaticFileModule" Notification: "ExecuteRequestHandler" Handler: "StaticFile" Error Code: "0x80070032" Requested URL: "http://camelotshiftmanagement.com:80/Scripts/Administration/OrganizationalStructure.js.axd" Physical Path: "C:\Code\CamelotShiftManagement\CamelotShiftManagement\Scripts\Administration\OrganizationalStructure.js.axd" Logon Method: "Anonymous" Logon User: "Anonymous" Most likely causes: The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler. Things you can try: If you want to serve this content as a static file, add an explicit MIME map.
Well, I'm over my league here ... I donโt understand why my custom handler is not called, but the StaticFile handler is called instead.