CSS does not load after publication in Azure

Asked

Viewed 125 times

-2

I published an Asp.Net Core 2.1 application in Azure, but the CSS does not work, so the application is all messed up. In development environment, my application works normally.

I noticed in devtools that it does not load any CSS or JS. But as I said, in development environment everything works normal.

How can I resolve this issue? Below follows files.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]</title>
    
    <environment include="Development">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/vendor/fontawesome/css/font-awesome.css" />
        <link rel="stylesheet" href="~/vendor/animate.css/animate.css" />
        <link rel="stylesheet" href="~/vendor/iCheck/skins/all.css" />
        <link rel="stylesheet" href="~/icons/pe-icon-7-stroke/css/pe-icon-7-stroke.css" />
        <link rel="stylesheet" href="~/css/site.css" />
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
              asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
        <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
    </environment>

    <!-- Google Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Quicksand:300,400,700' rel='stylesheet' type='text/css'>
</head>
<body class="fixed-navbar sidebar-scroll">

    <div id="header">
        @await Html.PartialAsync("_Header")
    </div>


    <aside id="menu">
        @await Html.PartialAsync("_Navigation")
    </aside>

    <div id="wrapper">
        @RenderBody()

        @await Html.PartialAsync("_Footer")
    </div>

    <environment include="Development">
        <script src="~/lib/jquery/dist/jquery.js"></script>
        <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
        <script src="~/vendor/slimScroll/jquery.slimscroll.js"></script>
        <script src="~/vendor/metisMenu/dist/metisMenu.js"></script>
        <script src="~/vendor/iCheck/icheck.js"></script>
        <script src="~/vendor/sparkline/index.js"></script>
        <script src="~/vendor/chartjs/Chart.min.js"></script>
        <script src="~/lib/jsMask/jquery.mask.min.js"></script>
        <script src="~/js/grifo.js"></script>
        <script src="~/js/site.js" asp-append-version="true"></script>
    </environment>
    <environment exclude="Development">
        <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
                asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                asp-fallback-test="window.jQuery"
                crossorigin="anonymous"
                integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
        </script>
        <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
                asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
                asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
                crossorigin="anonymous"
                integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
        </script>
        <script src="~/vendor/jquery-ui/jquery-ui.min.js" asp-append-version="true"></script>
        <script src="~/js/jquery-1.8.3.min.js" asp-append-version="true"></script>
    </environment>

    @RenderSection("Scripts", required: false)
</body>
</html>

  • Put the address that leads to css, for example http://seu_dominio.com/pasta_em_se_encontra_o_CSS/arquivo.css

  • 1

    Why use "~" in directories? And you put the folders that contain the css and js in Azur as well?

  • The use of "~" in directories is a convention of Asp.Net. It is already configured like this. If I change it doesn’t even work in @Pbras development environment

1 answer

1


Solved. Layouts View usually has tag formatting <enviroment include> and <enviroment exclude> as I posted in the question. I just delete this tags leaving the calls with default html tags like this:

<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/vendor/fontawesome/css/font-awesome.css" />
<link rel="stylesheet" href="~/vendor/animate.css/animate.css" />
<link rel="stylesheet" href="~/vendor/iCheck/skins/all.css" />
<link rel="stylesheet" href="~/icons/pe-icon-7-stroke/css/pe-icon-7-stroke.css" />
<link rel="stylesheet" href="~/css/site.css" />

Thank you all for your attention.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.