在MVC中,当我通过表单发布从一个控制器操作视图移动到另一个控制器操作视图时,未加载js和css文件,这些文件被添加到另一个控制器操作视图中。第一个控制器视图使用布局但第二个不使用 在第二个控制器操作中查看:
@{
Layout = null;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link type="text/css" rel="stylesheet" href="../../Css/ChatStyle.css" />
<link rel="stylesheet" href="../../Css/JQueryUI/themes/base/jquery.ui.all.css" />
<script src="../../Scripts/jquery-1.8.2.js"></script>
<script src="../../Scripts/ui/jquery.ui.core.js"></script>
<script src="../../Scripts/ui/jquery.ui.widget.js"></script>
<script src="../../Scripts/ui/jquery.ui.mouse.js"></script>
<script src="../../Scripts/ui/jquery.ui.draggable.js"></script>
<script src="../../Scripts/ui/jquery.ui.resizable.js"></script>
<script src="../../Scripts/jquery.signalR-1.0.0.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(document).ready(function () {
--------------large code related to signalR----------------
});
</script>
</head>
<body>
// content
</body>
</html>
如果我通过Crtl + F5使用直接第二个控制器动作视图。然后它的工作正常 在此先感谢
答案 0 :(得分:0)
当我在Html内容之后使用所有CSS和JS部分视图时,它的工作正常如下:
_chatLayout.cshtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="main">
@RenderBody()
</div>
<!-- /content -->
</body>
</html>
查看是:
@{
ViewBag.Title = "Chat window";
Layout = "~/Views/Shared/_chatLayout.cshtml";
}
<div>
// content
</div>
<link type="text/css" rel="stylesheet" href="../../Css/ChatStyle.css" />
<link rel="stylesheet" href="../../Css/JQueryUI/themes/base/jquery.ui.all.css" />
<script src="../../Scripts/jquery-1.8.2.js"></script>
<script src="../../Scripts/ui/jquery.ui.core.js"></script>
<script src="../../Scripts/ui/jquery.ui.widget.js"></script>
<script src="../../Scripts/ui/jquery.ui.mouse.js"></script>
<script src="../../Scripts/ui/jquery.ui.draggable.js"></script>
<script src="../../Scripts/ui/jquery.ui.resizable.js"></script>
<script src="../../Scripts/jquery.signalR-1.0.0.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(document).ready(function () {
-----large code related to signalR------
});
</script>