Jun*_*son 9 c# asp.net-mvc-5 visual-studio-2017
我在发布Visual Studio 2017,C#,ASP.Net MVC 5项目时遇到问题.我发布以下设置:
CSS内容链接问题,例如bootstrap:
@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);
Run Code Online (Sandbox Code Playgroud)
如果bootstrap.min.css位于localhost/bower_components/css/bootstraps/bootstrap.min.css,那css将显示为localhost/fonts/glyphicons-halflings-regular.eot客户端.
如果我只是复制粘贴所有项目而不将其发布到服务器,链接将正确显示为 localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot
所有css都会发生这种情况,包括css中的图像和其他文件.
利用您的问题中可用的代码知识以及显示和解释的内容.我可以在你的代码中看到你的相对路径有问题.
您正在使用../将其更改为./或~/.这应该解决问题.
通过使用../你正在踩过css路径.
小智 1
在 {YourProjectName}\App_Start\BundleConfig.Cs 中
添加 Bootstrap Bundle 时添加CssRewriteUrlTransform类的实例,如下所示:
public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
524 次 |
| 最近记录: |