MVC アプリケーション フォルダー内に Index.js と Index.css ファイルを配置しましたViews/MemberField
。
Copy always
両方のファイルに設定されています。
私はそれらをロードしようとしました:
<link href="@Url.Content("~/Views/MemberField/Index.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("~/Views/MemberField/Index.js")">
次の html 出力が得られます。
<link href="/Views/MemberField/Index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Views/MemberField/Index.js"></script>
ここまでは順調ですね。
しかし、2 つのファイルにはアクセスできません。
The resource cannot be found.
何らかのルーティング メカニズムが原因だと思うので、RouteConfig.cs ファイルを少し改ざんしました。
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.RouteExistingFiles = false;
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{file}.css");
routes.IgnoreRoute("{file}.js");
routes.MapRoute(
name: "Default"
, url: "{culture}/{controller}/{action}/{id}"
, defaults: new { culture = UrlParameter.Optional, controller = "GlobalSettings", action = "Index", id = UrlParameter.Optional }
, namespaces: new[] { "MygLogWeb" }
);
}
}
しかし、それは何も変わりませんでした。
どうしたの?