ASP MVC5にアプリケーションがありますが、ほとんどの場合、javascriptファイルを参照する際に問題が発生しますが、基本的にURLはmypage.com/admin/products/create 、スクリプトが呼び出され、うまく動作しますが、mypage.com/admin/products/edit/1525のような追加のパラメータを持つコントローラを呼び出すと、javascriptファイル参照に '../'を追加する必要があります。 '../'を使わないでjavascript内のイメージやパスへの参照だけでなく404の束を取得します。 私はセットアップ私のルートの中で何かが、わからないことが必要と考えている、これは私のrouteconfigURLにパラメータが多い場合はjavascriptを呼び出します
public static void RegisterRoutes(RouteCollection routes)
{
var namespaces = new[] {typeof (HomeController).Namespace} ;
var AdminNamespaces = new[] {typeof (Areas.Admin.Controllers.HomeController).Namespace};
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Home", "", new {controller = "Home", action = "Index"}, namespaces);
routes.MapRoute("Login", "login", new { controller = "Login", action = "Index" });
routes.MapRoute("Logout", "logout", new {controller = "Login", action = "Logout"});
}
であり、これは、私はそれが有用であろう含めることができる他に何
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"admin/{controller}/{action}/{id}",
new { action = "Index", controller = "Home", id = UrlParameter.Optional }
);
}
わからないエリア登録です
私は問題を抱えています一つの特定のスクリプトがniceditのテキストエディタで、私はこのような私のバンドルでそれを持っている:
bundles.Add(new ScriptBundle("~/scripts/nicedit")
//.Include("~/scripts/lodash.js")
.Include("~/scripts/nicedit.js")
);
最終的に私はちょうどこのようCSHTML(ないレイアウト)私の見解でそれを呼び出す:
@Scripts.Render("~/Scripts/nicedit")
JSファイル参照をどのように追加しますか?それはおそらく問題です。私はほぼ100%ルーティングに関係していません。 また、質問からasp-classicタグを削除しましたが、これは関連していません。 –
あなたのバンドルの設定を教えてください? –
バンドルを追加するために編集され、ビューからどのように呼び出されますか – HectorDZJ