アプリケーションで使用される JavaScript ファイルをローカライズするために HTTP ハンドラーを使用しています。「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) Views フォルダの web.confing ファイルに行を追加<add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" />
したので、次のようになります。
<system.web>
<httpHandlers>
<add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
それでも、次の URL にアクセスしようとすると、ページが見つかりませんというエラーが表示されます。
http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd
ここで何が間違っていますか?
進行状況: わかりました、厄介な間違いを発見しました...何らかの理由で、 Handler を追加する
*.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ハンドラーが呼び出される理由がわかりません。