IIS express在一个文件夹中不显示index.cshtml,但在另一个文件夹中显示 [英] IIS express doesn't show index.cshtml in one folder but in other it shows
问题描述
我正在使用C#和.Net Framework 4.7开发ASP.NET MVC 5应用程序.
I'm developing an ASP.NET MVC 5 application with C# and .Net Framework 4.7.
我刚刚创建了一个新的ASP.NET MVC 5控制器:
I've just created a new ASP.NET MVC 5 controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace TRZF.Web.API.Controllers
{
public class ReportsController : Controller
{
// GET: Reports
public ActionResult Index()
{
return View();
}
}
}
我在Index
方法上单击鼠标右键,然后选择Add View...
.它在文件夹.\Views\Reports
中创建了一个名为Index.cshtml
的新cshtml
文件,其内容如下:
I have right clicked at Index
method and select Add View...
. It has created a new cshtml
file in folder .\Views\Reports
called Index.cshtml
with this content:
@{
ViewBag.Title = Resources.ReportsIndexTitle;
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Styles
{
<link href="~/css/tables.css" rel="stylesheet" />
<link href="~/css/jquery-ui.css" rel="stylesheet" />
}
@section Body
{
<div class="bodyBackground1">
<div class="titulo">
<h2>@Resources.ReportsIndexHeader</h2>
</div>
<div class="formPO">
</div>
<div class="footer">
<p>@Resources.ViewGenericInvConCopyright</p>
</div><!-- end .footer -->
</div>
}
@section scripts
{
}
我用它来导航到该文件:
I use this to navigate to that file:
@Html.ActionLink(Resources.GetReports, "Index", "Reports")
但是我在ReportsController.Index
方法中添加了一个断点,并且它并没有停止.
But I have added a breakpoint at ReportsController.Index
method and it doesn't stop.
我有更多的控制器正在工作,我对它们所做的我已经知道的相同,但是这个不起作用.他们所有的人都可以正常工作,显示他们的索引页并在Index
方法处停止,但是当我尝试使用它时,我得到一个显示HTTP Error 403.14 - Forbidden
的屏幕.
I have a lot of more Controllers working and I did the same with them that I've done know but this one doesn't work. All of them works perfectly, showing their index page and stopping at Index
method but when I try this one I get a screen with HTTP Error 403.14 - Forbidden
.
这是怎么回事?
推荐答案
出现HTTP Error 403.14 - Forbidden
错误的最可能原因是您的应用中还有一个名为Reports
的文件夹,因此该应用尝试导航到您的文件夹,而不是您的控制器方法.
The most likely cause for your HTTP Error 403.14 - Forbidden
error is that you also have a folder in your app named Reports
so its attempting to navigate to your folder, rather than your controller method.
如果是这样,则将该文件夹重命名为除控制器之一之外的其他名称.
If so rename that folder to anything other than the name of one of your controllers.
这篇关于IIS express在一个文件夹中不显示index.cshtml,但在另一个文件夹中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!