Glifikony Twittera bootstrap nie pojawiają się w trybie release 404
Pracuję nad projektem w ASP.NET MVC 4 i zrobiłem następujące kroki:
Pobrano twitter bootstrap z http://blog.getbootstrap.com/2013/12/05/bootstrap-3-0-3-released/
-
Ustawia akcję budowania plików czcionek na zawartość (pliki znajdują się w folderze ~/Content/font)
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
-
Dodano do RouteConfig.cs
Trasy.IgnoreRoute ("{folder} / {*pathInfo}", new { folder = " Content" });
-
Dodano następujące elementy do Web.config
<?xml version="1.0" encoding="UTF-8"?> <system.webServer> <staticContent> <remove fileExtension=".eot" /> <remove fileExtension=".ttf" /> <remove fileExtension=".otf"/> <remove fileExtension=".woff"/> <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" /> <mimeMap fileExtension=".ttf" mimeType="font/ttf" /> <mimeMap fileExtension=".otf" mimeType="font/otf" /> <mimeMap fileExtension=".woff" mimeType="font/x-woff" /> </staticContent> </system.webServer>
-
Zawiera następujący kod w BundleConfig.cs
bundles.Add(new StyleBundle("~/bundles/maincss") .Include("~/Content/bootstrap/bootstrap.css") .Include("~/Content/bootstrap/bootstrap-theme.css") .Include("~/Content/hbl-full.css"));
Wypróbowano również następujący kod
IItemTransform cssFixer = new CssRewriteUrlTransform(); bundles.Add(new StyleBundle("~/bundles/maincss") .Include("~/Content/bootstrap/bootstrap.css", cssFixer) .Include("~/Content/bootstrap/bootstrap-theme.css", cssFixer) .Include("~/Content/hbl-full.css", cssFixer));
-
Wywołane w głównym układzie.cshtml
@Styles.Render ("~/bundles / maincss")
Nadal w localhost ikony są wyświetlane normalnie, ale kiedy wciskam kod do serwera release, widzę tylko kwadrat zamiast ikony i w zakładce konsola Chrome dostaję
Dziękuję.GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.woff 404 (Nie znaleziono) test: 1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.ttf 404 (Nie znaleziono) test: 1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.svg 404 (Nie znaleziono) test: 1
7 answers
Miałem ten problem i stwierdziłem, że dzieje się to z powodu minifikacji podczas budowania w trybie release.
Zamiast pobierać pliki ręcznie ze strony bootstrap i konfigurować Wiązanie używam pakietu nuget, który robi to za mnie.
Jeśli chcesz to zrobić, wykonaj następujące kroki.
Uruchom następujące polecenie, aby zainstalować Bootstrap:
Install-Package Twitter.Bootstrap.MVC
To pobiera wszystkie pliki rozruchowe i zawiera poniższy wstępnie zdefiniowany pakiet rozruchowy config:
public class BootstrapBundleConfig
{
public static void RegisterBundles()
{
// Add @Styles.Render("~/Content/bootstrap") in the <head/> of your _Layout.cshtml view
// For Bootstrap theme add @Styles.Render("~/Content/bootstrap-theme") in the <head/> of your _Layout.cshtml view
// Add @Scripts.Render("~/bundles/bootstrap") after jQuery in your _Layout.cshtml view
// When <compilation debug="true" />, MVC4 will render the full readable version. When set to <compilation debug="false" />, the minified version will be rendered automatically
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js"));
BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap").Include("~/Content/bootstrap.css"));
BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap-theme").Include("~/Content/bootstrap-theme.css"));
}
}
Powyższe zawiera również komentarze opisujące jak renderować Pakiety.
Myślę, że oryginalny błąd Czcionki 404 był spowodowany tym, że folder fonts był na innym poziomie niż określony w minifikowanym css.
Jeśli wolisz zachować obecne rozwiązanie, jedynym sposobem na naprawienie 404 było skopiowanie folderu czcionek do katalogu głównego aplikacji internetowej.
Aby przetestować go lokalnie, po prostu usuń {[2] } Z konfiguracji sieci Web, aby zapisać wdrożenie do AppHarbor.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-22 09:11:10
Oto Jak to rozwiązałem -- używam MVC5 i Bootstrap 3.1.1 .
Moje pliki są uporządkowane w projekcie tak:
/Content/Bootstrap/bootstrap.css
bootstrap.min.css
/Content/fonts/glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
Następnie dodałem kolejny poziom do mojej wirtualnej ścieżki w bundle config
bundles.Add(new StyleBundle("~/Content/site/css").Include(
"~/Content/bootstrap/bootstrap.css",
"~/Content/styles/site.css"
));
Poprzednio używałem ~/Content/css
I w widoku ...
@Styles.Render("~/Content/site/css")
To zadziałało, ale wciąż mam 404 na jednej z czcionek... więc dodałem rozwiązanie Gilesa.
<?xml version="1.0" encoding="UTF-8"?>
<system.webServer>
<staticContent>
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".otf"/>
<remove fileExtension=".woff"/>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
</system.webServer>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-02 17:26:46
Kopiowanie folderu czcionek do katalogu głównego aplikacji internetowej i zmiana typów mime w web.config to
<?xml version="1.0" encoding="UTF-8"?>
<system.webServer>
<staticContent>
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".otf"/>
<remove fileExtension=".woff"/>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
Naprawiono problem dla mnie. Należy pamiętać ,że.typ MIME woff jest inny niż ten w pytaniu.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-28 11:33:41
Miałem ten sam problem, używając IIS 7.5 webserver.
Rozwiązaniem było dodanie .woff do listy rozszerzeń nazw plików z typem MIME application / octet-stream na serwerze WWW.
Można również osiągnąć to samo w sieci.config:
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/octet-stream" />
</staticContent>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-02 12:48:57
Miałem ten sam problem. Naprawdę Nie wiem dlaczego, ale jeśli usunę bootstrap./ min.plik css i ustawić CssRewriteUrlTransform na Pakiecie Wszystko działa. Używam bootstrap v3. 1. 1
Edytuj: Po pewnym zbadaniu rozwiązanie jest zdefiniowane tutaj: CssRewriteUrlTransform nie jest wywoływany Więc usuwam bootstrap./ min.css lub odwoływanie się do bootstrap./ min.css zamiast bootstrap.css wymusi Wiązanie / minifikację na Twoim pliku, a więc wywoła CssRewriteUrlTransform.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:33:15
Miałem ten sam problem. Obejrzałem go za pomocą CDN Bootstrapa.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-23 03:07:22
W IgnoreRoute
podałeś folder "Content". Spróbuj również dodać jeden dla czcionek", ponieważ o to prosisz.
routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "fonts" });
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-21 22:26:32