gpt4 book ai didi

c# - ASP.NET MVC4 不在 IIS 中呈现布局

转载 作者:行者123 更新时间:2023-11-30 13:58:51 25 4
gpt4 key购买 nike

使用 ASP.NET 和 MVC 已经有几年了,以前从未见过这个......

刚收到一台新机器。创建了一个新的 MVC4 Web 项目(对于 Internet,在向导中)。我正在“开箱即用”地使用该项目来测试是否已正确设置和配置所有内容。

如果我使用内置的 Web 服务器从 Visual Studio (2010) 运行它,那么一切都很好。但是,我在 IIS 中设置了一个应用程序,它没有呈现布局(默认生成的代码位于 ~/Views/Shared/_Layout.cshtml 的默认位置)但我确实得到了 Index.cshtml(~/Views/Home/Index.cshtml)。 cshtml) 内容。布局中的任何内容都不会呈现:没有 html 标记、没有样​​式、没有 javascript、没有 body 标记,什么都没有。

是否进行了基本诊断... IIS 中没有出现服务器错误。事件/应用程序日志中没有任何错误记录。 Chrome 网络检查器工具中没有显示任何内容(甚至没有 404 或 500)。

有什么想法吗?我很难过...感觉它非常非常简单。

Index.cshtml(默认生成的代码,底部的测试代码除外,只是为了确保正确获取 MVC dll):

<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>

<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>

<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>

@foreach(var i in new int[]{1,2,3,4,5})
{
<div>Test @i.ToString()</div>
}

在 Chrome 中呈现:

<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>

<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>

<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>

<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
<div>Test 5</div>

最佳答案

所以,这是最终的解决方案(羞愧地低下头):

首先打开IIS,点击网站,打开IIS组下的Authentication设置,点击Anonymous Authentication,点击右侧Actions面板中的“Edit”。在这里,请注意匿名身份验证是如何执行的。它可以是特定用户或应用程序池目录。

无论哪种方式,您都需要确保此帐户在您提供站点的目录的安全对话框中具有适当的权限。在我的例子中(我相信默认情况下,因为这是一个全新的盒子)它将被设置为特定用户:IUSR。如前所述,为该用户提供读取/执行文件的适当权限,您应该一切顺利。

让我失望的是,我试图在网站上加载静态文件,如 css 或图像,但我收到 404 或重定向以登录这些文件(我尝试了一些关于帐户和权限的不同解决方案).

引用资料:

关于c# - ASP.NET MVC4 不在 IIS 中呈现布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15122535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com