Bootstrap Icons not showing in published ASP.NET MVC application

后端 未结 17 1964
孤城傲影
孤城傲影 2021-01-30 11:30

--- NB: Go to the EDITED 2 section for summary ----

I have an ASP.NT MVC (4) application. I integrated (twitter)Bootstrap to it. Bootstrap is working perfectly, but the

相关标签:
17条回答
  • 2021-01-30 11:47

    IIS doesn't know how to handle (serve) those files (MIMEs).

    Add this to your system.webServer node in the web.config file and you'll be golden:

    <staticContent>    
          <mimeMap fileExtension=".otf" mimeType="font/otf" />
          <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
          <!-- add more MIMEs if needed... -->
    </staticContent>
    

    --Edited, see Ryans and mine comment below: Even better, to be safe, remove and add the mime type maping:

    <staticContent>    
        <remove fileExtension=".otf" />
        <mimeMap fileExtension=".otf" mimeType="font/otf" />
        <remove fileExtension=".woff" />
        <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
        <!-- add more MIMEs if needed... -->
    </staticContent>
    
    0 讨论(0)
  • 2021-01-30 11:51

    You have to set the property Copy to Output Directory of the files on Copy always

    0 讨论(0)
  • 2021-01-30 11:56

    I was also having this issue with MVC 5 and Bootstrap v3.3.6.

    Failed to load resource: the server responded with a status of 404 (Not Found) http://NameOfSite/Error/NotFound?aspxerrorpath=/bundles/fonts/glyphicons-halflings-regular.woff2

    You need to update the @icon-font-path in theContent/bootstrap/variables.less file from "../fonts/"; to "/Content/fonts/";

    0 讨论(0)
  • 2021-01-30 11:56

    Have you included your bootstrap files into the project? Only the files, included into the solution are to be published.

    0 讨论(0)
  • 2021-01-30 11:59

    I had this problem too. Rather than have to move files around you can create a virtual directory in the root of the project in IIS.

    0 讨论(0)
提交回复
热议问题