我使用的是HTTP处理程序本地化在我的应用程序使用的JavaScript文件:看到: 在ASP.NET JavaScript文件本地化文本
我想用这样提供的处理程序,我做了以下内容:
1)在Global.asax中使用此代码忽略路线-我已经添加了routes.IgnoreRoute("{resource}.js.axd/{*pathInfo}");
的代码行RegisterRoutes
方法,所以它看起来是这样的:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.js.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
2)I已经添加<add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" />
所以它看起来像这条线在视图文件夹我web.confing文件:
<system.web>
<httpHandlers>
<add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
然而,我得到一个找不到网页错误,当我尝试访问以下网址:
http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd
我在做什么错在这里?
进展情况:好吧,我发现了一个尴尬的错误,我做...出于某种原因,我认为增加一个处理程序时
*.js.axd
会发现文件,但实际上它并没有因为该文件被命名为OrganizationalStructure.js
不用其他该.axd
扩展。 所以这是404错误的原因,但现在我从服务器获取不同的错误,我再次需要你的帮助。
访问http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd
产生了不同的错误这个时候:404.17请求的内容似乎是脚本,并不会由静态文件处理程序提供服务。
其他错误信息
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.
好吧,我的方式在我的联赛在这里...我不明白为什么我的自定义处理程序不被调用,而是一个StaticFile处理程序被调用。