--注:请到编辑后的第2节进行摘要
我有一个ASP.NT MVC (4)应用程序。我整合了(推特)引导到它。引导程序运行得很好,但是当我发布应用程序时,图标没有正确显示。
我试图重新发布应用程序,但没有成功。
为了澄清,我在下面放了一些图片。
当我从VS2013运行我的应用程序时,结果是这样的(这是可以的):

在booth,IE和Chrome。
但是,当我运行已发布的应用程序时,结果是这样的(这是不好的):


这个问题在某种程度上与评估的CSS有关,但我不知道在什么时候会发生这种情况。
本地应用程序中的评估css如下(这是可以的):


但在已发布的应用程序中,我有以下(这是不合适的):


有些人经历过这种行为?
我能做些什么来解决这个奇怪的问题?
···
在发布我的应用程序时,我会获得要包含的字体文件(.eot、.svg、.ttf和.woff)。当我访问默认页面(应用程序根http://localhost/)时,即显示图标的页面,Chrome网络选项卡中显示的文件如下:

在包含这些文件之前,我收到了404个文件错误,所以我可以猜测,即使它们没有显示在Network中,也会继续被请求。
不过,图标没有正确显示。
编辑2?
嗯,我在IIS 7中重新启动了我的站点,并且请求开始被触发。这些文件请求显示在Chrome的Developper Network Tab中:

然后,resquest将在:/Content/themes/fonts/中查找文件,但它们在:/Content/themes/base/fonts/中。
base文件夹包含一个包含bootstrap.css文件的bootstrap文件夹。在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');
    }但是,我知道这是怎么回事,以及如何解决它!此外,图标将显示在发布的网站,但不在本地网站(运行从VS2013与iisexpress)。,谢谢您的帮助!
发布于 2014-03-06 15:27:55
IIS不知道如何处理(服务)这些文件(MIME)。
将其添加到system.webServer文件中的web.config节点中,您将是黄金:
<staticContent>    
      <mimeMap fileExtension=".otf" mimeType="font/otf" />
      <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
      <!-- add more MIMEs if needed... -->
</staticContent>-编辑,见Ryans和我下面的评论:更好的是,为了安全起见,删除并添加mime类型的映射:
<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>发布于 2013-12-13 09:43:50
尝试禁用包优化,所发生的情况是绑定的css样式表的路径与引用的图像冲突。例如。您可能在一个包"~/Content/ css“中有一个css文件/Content/css/style.css,其中指定了这样的图像。
    .someclass { background-image:url(img/someimg.png) }这将将图像解析为/Content/css/img/omeimg.png
现在部署发行版构建,css文件现在呈现到一个包URL,如/Content/css,现在图像URL解析为/Content/img/omeimg.png
您可以在App_Start\BundleConfig.cs中更改此行为。
    System.Web.Optimization.BundleTable.EnableOptimizations = false;发布于 2013-12-13 09:29:08
运行Fiddler或使用浏览器开发工具上的网络选项卡。您应该查找的是下载字体文件的请求的404结果。
还请确保发布的站点包含~/Fonts/glyphicons-halflings-regular.[eot,svg,ttf,woff]文件。
您在计算的CSS规则中看到的差异是由于缩小了CSS文件(由debug=true/false设置在web.config文件中控制)。值\e013只是另一种书写符号的方式。
https://stackoverflow.com/questions/20563001
复制相似问题