With ASP.NET MVC 5 and Bootstrap 3 default install, why do styles get a 403 error and fonts throw a 404?

前端 未结 2 1925
甜味超标
甜味超标 2021-02-14 17:51

With a default install of ASP.NET MVC 5 and an updated Bootstrap 3, loading my project\'s home page does not display CSS styles or the included font glyphicons (404 file not fou

2条回答
  •  再見小時候
    2021-02-14 18:54

    When you install Bootstrap 3 into the Content folder, it includes a folder structure like this:

    ~/Content/css/boostrap.min.css
    ~/Content/fonts/glyphincons-halflinkgs-regular.(eot|svg|ttf|woff)
    

    The 403 "Forbidden" error, is likely because the default CSS bundle route "~/Content/css" matches a valid folder name, and MVC cannot resolve the conflict between a route and folder.

    Fix the 403 by renaming your route to something that doesn't match a real folder like, "~/Content/cssbundle".

    When you change the bundle name, the 404 "file not found" error occurs for the fonts as the relative path from the CSS files to the fonts is no longer valid.

    Fix the 404 by moving your fonts folder to the root of your project. (I wish I had a better solution here)

提交回复
热议问题