部署MVC5项目Azure的时候忽略CSS [英] CSS ignored when deploying MVC5 project to Azure

查看:203
本文介绍了部署MVC5项目Azure的时候忽略CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制定了一个MVC5网站和其部署到Azure的网站。该网站工作正常,但是,浏览到Azure中托管的网站,该网站会忽略我已经到默认bootstrap.css文件所做的更改。该文件被设置为一直拷贝到输出目录,所以它在Azure的present以及与$​​ C $ C的其余部分。

刷新的浏览器不显示的网站,因为它应该被显示。无论是否重新启动蔚蓝的网站帮助。下面是我的code:

Site.master母

 <头=服务器>
<间的charset =UTF-8/>
< META NAME =视口CONTENT =WIDTH =设备宽度,初始规模= 1.0/>
<标题>标题< /标题>< ASP:占位符=服务器>
    <%:Scripts.Render(〜/包/ Modernizr的)%>
< / ASP:占位符>
< webopt:bundlereference =服务器路径=〜/内容/ CSS/>
<链接HREF =〜/ favicon.ico的相对=快捷方式图标类型=图像/ X-图标/>< /头>
<身体GT;
*默认的Site.Master文件的休息*

Bundle.config

 <捆绑版本=1.0>
    < styleBundle路​​径=〜/内容/ CSS>
        <包含路径=〜/内容/ bootstrap.css/>
        <包含路径=〜/内容/的site.css/>
    < / styleBundle>
< /捆绑>


解决方案

解决方法找到

我设法让我通过执行以下操作预期的行为。可能不是最好的方法,但它的功能,我无法看到它的任何重大缺陷。

在的Site.Master,替换此行:

 < webopt:bundlereference =服务器路径=〜/内容/ CSS/>

这些的:

 <链接HREF =〜/内容/ bootstrap.css的rel =stylesheet属性类型=文/ CSS=服务器/>
<链接HREF =〜/内容/的site.css的rel =stylesheet属性类型=文/ CSS=服务器/>

I have developed a website on MVC5 and deployed it to Azure websites. The site works as expected but on browsing to the website hosted in Azure, the site ignores the changes I have made to the default bootstrap.css file. This file is set as "Copy Always" to the output directory, so it is present in Azure as well with the rest of the code.

Refreshing the browser does not show the website as it should be displayed. Neither does restarting the azure website help. Below is my code:

Site.master

<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />       
<title>Title</title>

<asp:PlaceHolder runat="server">
    <%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />        
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
*Rest of default Site.Master file*

Bundle.config

<bundles version="1.0">
    <styleBundle path="~/Content/css">
        <include path="~/Content/bootstrap.css" />
        <include path="~/Content/Site.css" />
    </styleBundle>
</bundles>

解决方案

Workaround found

I managed to get the behavior I am expecting by doing the following. Might not be the best approach, but it is functional and I can't see any major flaws on it.

On Site.Master, replace this line:

   <webopt:bundlereference runat="server" path="~/Content/css" />

with these ones:

<link href="~/Content/bootstrap.css" rel="stylesheet" type="text/css" runat="server" />
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" runat="server" />

这篇关于部署MVC5项目Azure的时候忽略CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆