CSS ignored when deploying MVC5 project to Azure

久未见 提交于 2019-12-23 16:26:20

问题


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>

回答1:


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" />



回答2:


If you modified bootstrap.css you need to update the minified version bootstrap.min.css as well.

You can do that easily at: cssminifier.com

For details on how to update the minified version, check out this question



来源:https://stackoverflow.com/questions/20791051/css-ignored-when-deploying-mvc5-project-to-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!