my layout page is working properly on 9 different views (all of them index.cshtml)
when i add some another view for the controller, layout is still working but css and js files doesn’t work properly. Is anyone experienced same situation on MVC app (.net 8) ?
To test ; i have added TestController , for the index method i have created Index view and layout worked properly again…
@{
ViewData["Title"] = "Some Title";
Layout = "~/Views/Shared/_Layout.cshtml";
}
this how index views starts.
My bundleconfig file;
[
{
"outputFileName": "wwwroot/css/site.min.css",
// An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optinally generate .map file
"sourceMap": false
}
]
Layout file head section ;
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title</title>
<link rel="icon" href="images/2gurmepatilogo.jpg" type="image/gif" sizes="20x20">
<!-- css file link -->
<link rel="stylesheet" href="css/all.css">
<link rel="stylesheet" href="css/animate.css">
<!-- bootstrap 5 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- box-icon -->
<link rel="stylesheet" href="css/boxicons.min.css">
<!-- bootstrap icon -->
<link rel="stylesheet" href="css/bootstrap-icons.css">
<!-- jquery ui -->
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" href="css/aos.css">
<!-- swiper-slide -->
<link rel="stylesheet" href="css/swiper-bundle.css">
<!-- nice-select -->
<link rel="stylesheet" href="css/nice-select.css">
<!-- magnefic popup css -->
<link rel="stylesheet" href="css/magnific-popup.css">
<!-- animate css -->
<link rel="stylesheet" href="css/jquery.fancybox.min.css">
<!-- odometer css -->
<link rel="stylesheet" href="css/odometer.css">
<!-- style css -->
<link rel="stylesheet" href="css/datepicker.min.css">
<!-- style css -->
<link rel="stylesheet" href="css/uiicss.css">
<!-- style css -->
<link rel="stylesheet" href="css/style.css">
</head>
layout file js references ;
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery.timepicker.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/swiper-bundle.min.js"></script>
<script src="js/jquery.nice-select.js"></script>
<script src="js/jquery.fancybox.min.js"></script>
<script src="js/morphext.min.js"></script>
<script src="js/odometer.min.js"></script>
<script src="js/jquery.marquee.min.js"></script>
<script src="js/viewport.jquery.js"></script>
<script src="js/isotope.pkgd.min.js"></script>
<script src="js/SmoothScroll.js"></script>
<script src="js/jquery.nice-number.min.js"></script>
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/masonry.pkgd.min.js"></script>
<script src="js/main.js"></script>
</html>
i have tried to put them inside body also but nothing changed.
I have created second action method in the controller and view for that method. In that view from layout html codes are working but css and js are not working.
I have copied html/css/js template inside mvc app , i haven’t used Libman.
Emre Pelte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.