MVC应用程序在VS2017中运行正常。当我将应用程序发布到Windows 8 IIS 8.5时,也很好。但是,当我将其发布到Windows Server 2012 R2时,它会引发异常
~/Views/Home/statroom.aspx
~/Views/Home/statroom.ascx
~/Views/Shared/statroom.aspx
~/Views/Shared/statroom.ascx
~/Views/Home/statroom.cshtml
~/Views/Home/statroom.vbhtml
~/Views/Shared/statroom.cshtml
~/Views/Shared/statroom.vbhtml
我的代码:
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public ActionResult StatRoom()
{
return View();
}
}
我的视图\ Views \ Home \ StatRoom.cshtml
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>StatRoom</title>
<link href="~/Styles/index.css" rel="stylesheet">
</head>
<body>
<div id="div1">
<div id="div11">
<img id="photo" src="~/Images/Default.jpg" height="100%"
width="100%">
</div>
</div>
<div id="div2">
<div id="div21">
</br>
</br>
<h id="hd1"> 2321 </h>
<div id="div211">
<h id="hd2"> </h>
</div>
</div>
</div>
<div id="div3">
<div id="div311">
<p id="hp">TITLE</p>
<div id="div312">
<br />
<h id="hd3">NAME SURNAME </h>
<br />
<hr style="width: 300px;" />
<br />
<h id="branch"> DIVISION</h>
<div id="div313">
</div>
</div>
</div>
</div>
<div id="div4">
<div id="div41">
<h id="h4" style="color: white;"> </h>
<div id="div412">
<h id="hd" style="color: white;"> </h>
<br />
<div>
</div>
</div>
</div>
</div>
<script src="~/Scripts/jquery-1.6.4.js"></script>
<script src="~/Scripts/jquery.signalR-2.4.0.js"></script>
<script src="/signalr/hubs"></script>
</body>
</html>
<script>
$(document).ready(function () {
$.connection.hub.start();
var chat = $.connection.triggerHub;
chat.client.privateMessage = function (messageID, action, message) {
console.log(messageID);
console.log(action);
console.log(message);
switch (action){
case 1:
Init(message);
break;
case 2:
window.location.reload(true);
break;
case 3:
document.getElementsByTagName('body')[0].innerHTML = message;
break;
}
};
});
function Init(message) {
try {
var res = JSON.parse(message);
$('#hd1').text(res.roomnr);
$('#hd3').text(res.doctorname);
$('#hp').text(res.title);
$('#branch').text('-' + res.branch + '-');
if (res.photourl !== '')
$("#photo").attr('src', res.photourl);
else
$("#photo").attr('src', '~/Images/Default.jpg');
}
catch (err) {
console.log(err.message);
}
}
</script>
相同的代码,相同的已发布文件,但不起作用。我将数据以JSON格式从服务器发送到客户端,这就是为什么我不将模型数据从控制器传递到视图的原因。
我从引用中删除了Microsoft.CodeDom.Providers.DotNetCompilerPlatform(因为在该dll的服务器中出现错误),并从Web配置中删除了system.codedom部分。但是我不确定这个问题是否与这个问题有关。还创建了新的MVC VS模板应用程序,对其进行了部署并获得了相同的结果。