--- 注意:请前往编辑 2 部分查看摘要 ----
我有一个 ASP.NET MVC (4) 应用程序。我将 (twitter)Bootstrap 集成到其中。
Bootstrap 工作正常,但当我发布应用程序时,图标无法正确显示。
我尝试重新发布该应用程序,但没有成功。
为了清楚起见,我在下面放了一些图片。
当我从 VS2013 运行我的应用程序时,结果是这样的(没问题):
展位上有 IE 和 Chrome。
但是当我运行已发布的应用程序时,结果是这样的(这是不行的):
不知何故,这个问题与评估的CSS有关,但我不知道这会在什么时候发生。
本地应用程序中评估的 css 是这样的(这是可以的):
但在已发布的应用程序中,我有这个(这是不行的):
有些人经历过这种行为吗?
我能做些什么来解决这个奇怪的问题?
--------------------------- 已编辑 ---------------------- --------
我得到字体文件(.eot
, .svg
, .ttf
and .woff
)在发布我的应用程序时包含在内。
当我访问默认页面(应用程序根目录http://localhost/
)这是显示图标的页面 Chrome 的开发者工具网络选项卡中显示的文件是:
在包含这些文件之前,我收到了这些文件的 404 错误,因此我可以猜测即使它们没有显示在“网络”选项卡中,也会继续请求它们。
但是,图标没有正确显示。
------------------------ 已编辑 2 ------------------------ ---
好吧,我在 IIS 7 中重新启动我的站点。请求开始被触发。这些是 Chrome 开发者工具网络选项卡中显示的文件请求:
然后,该请求将在以下位置查找文件:/Content/themes/fonts/
但他们在:/Content/themes/base/fonts/
The base
文件夹包含一个bootstrap
文件夹包含bootstrap.css
文件。在 CSS 文件中,有此类引用字体文件:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
看来对字体文件的引用很好,因为文件树是这样的:
我可以将课程更改为:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../base/fonts/glyphicons-halflings-regular.eot');
src: url('../base/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../base/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../base/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../base/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
但是,我实际上会知道发生了什么以及如何解决它!
此外,图标将显示在已发布的站点中,但不会显示在本地站点中(从带有 iisexpress 的 VS2013 运行)。预先感谢您的帮助!