ASP.NET MVC RouteConfig 設定讓瀏覽器能取得根目錄的 html
讓瀏覽器能使用靜態檔案,例如: html, js, css
其它格式必須再加設 MIME type
MIME 的設定方式:
以加設一個 .woff 字型為例:
其它格式必須再加設 MIME type
public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute(""); // 加入這一行即可 //routes.RouteExistingFiles = true; routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } }
MIME 的設定方式:
以加設一個 .woff 字型為例:
<system.webServer> ... <staticContent> <remove fileExtension=".woff" /> <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> </staticContent> </system.webServer>
留言
張貼留言