我对Windows 2019上的IIS上运行的MVC不太满意,即使尝试使用VS生成的新测试站点也是如此。
应用程序使用IIS Express
作为 https:// localhost:44358 可以正常运行,但是在IIS上失败。
在主站点上,我add application..
使用IIS管理器,别名和物理路径。
应用程序无法启动。
我能够跟踪一些代码,然后IIS通过注册路由失败,并显示以下内容:
Object reference not set to an instance of an object.
然后是
的简短html代码Source File: C:\inetpub\<redacted>\Views\Shared\_Layout.vbhtml Line: 40
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Views_Shared__Layout_vbhtml.Execute() in C:\inetpub\<redacted>\Views\Shared\_Layout.vbhtml:40
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
System.Web.WebPages.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer) +232
...
引用 @Html.ActionLink
。
接下来,我尝试将其作为网站运行:在IIS管理器上Add Website
上,填写站点,物理路径和主机名,结果相同。
我怀疑定义@ Html.ActionLink的dll没有正确加载,没有任何线索来检查或修复。
完整来源
这里在其他地方使用了一些功能,按预期工作。
<!DOCTYPE html>
<html>
<head>
@code
Tell(True, $"_Layout. {TraceBack()}")
End Code
<!-- Must run in a domain logged pool with SQL access -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title </title>
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/fajs")
@Styles.Render("~/bundles/css")
<style type="text/css">
td {
vertical-align: top;
}
.absolute-bottom {
position: absolute;
bottom: 0em;
}
</style>
</head>
<body class="m-1 p-1">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" style="border:0px transparent;">
<i class="fas fa-bars"></i>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<i class="fas fa-home" style="width:2em;color: Dodgerblue;"></i>
Html.ActionLink("Home", "Index", "Intranet")
</li>
<li>
<i class="fas fa-ice-cream" style="width:2em;color: Dodgerblue;"></i>
Html.ActionLink("Icons", "Icons", "Intranet")
</li>
<li>
<i class="fas fa-money-bill" style="width:2em;color: Dodgerblue;"></i>
Html.ActionLink("Deals", "Deals", "Intranet")
</li>
<li>
<i class="fas fa-concierge-bell" style="width:2em;color: Dodgerblue;"></i>
@Html.ActionLink("Contact", "Contact", "Intranet")
</li>
<li>
<i class="fas fa-address-book" style="width:2em;color: Dodgerblue;"></i>
@Html.ActionLink("About", "About", "Intranet")
</li>
</ul>
<p class="nav navbar-text navbar-right">Identity: @WebIdentity.Name @WebIdentity.AuthenticationType @WebIdentity.User.Value</p>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<footer class="card-footer align-bottom">
<p class="text-center text-capitalize">
© <redacted> @DateTime.Now.ToShortDateString()
@WebDomain\@WebUserName
<!-- (@WindowsIdentity.Name) @WebIdentity.AuthenticationType @WebIdentity.IsAuthenticated -->
</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required:=False)
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('*[data-autocomplete-url]')
.each(function () {
$(this).autocomplete({
source: $(this).data("autocomplete-url")
});
});
});
</script>
</body>
</html>
✔注意
由于IIS和MVC引擎内部的异步工作,因此诊断消息具有误导性。
该错误是我自己的支持例程之一。
处理@ html.ActionLink(.....)时,在正确实例化之前使用了我的一个类。
几天后我将删除此问题。谢谢!