lon*_*gda 3 c# iis-7 visual-studio-2010 windows-7 asp.net-mvc-4
一直在使用ASP.NET和MVC几年,之前从未见过这个......
刚收到一台新机器.创建了一个新的MVC4 Web项目(用于Internet,在向导中).我正在使用"开箱即用"的项目来测试所有设置和配置是否正确.
如果我使用内置的Web服务器从Visual Studio(2010)运行它,那么一切都很好.但是,我在IIS中设置了一个应用程序并且它没有呈现布局(默认生成的代码位于〜/ Views/Shared/_Layout.cshtml的默认位置)但是我确实得到了Index.cshtml(〜/ Views/Home/Index). 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>
}
Run Code Online (Sandbox Code Playgroud)
在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>
Run Code Online (Sandbox Code Playgroud)
所以,这是最终的解决方案(羞愧地抱头):
首先,打开IIS,单击网站,打开IIS组下的身份验证设置,单击匿名身份验证,然后单击右侧"动作"面板中的"编辑".在这里,请注意匿名身份验证是如何执行的.它可以是特定用户或应用程序池目录.
无论哪种方式,您都需要确保此帐户在您为您的网站提供服务的目录的安全对话框中具有适当的权限.在我的情况下(默认情况下,我相信,因为这是一个全新的盒子),它将设置为特定用户:IUSR.如上所述,为该用户提供读取/执行文件的正确权限,您应该好好去.
让我知道的是,我试图在网站上加载静态文件,如css或图像,我得到404或重定向登录这些文件(我正在尝试一些关于帐户和权限的不同解决方案).
参考文献:
| 归档时间: |
|
| 查看次数: |
7226 次 |
| 最近记录: |