IIS express在一个文件夹中不显示index.cshtml,但在另一个文件夹中显示 [英] IIS express doesn't show index.cshtml in one folder but in other it shows

查看:111
本文介绍了IIS express在一个文件夹中不显示index.cshtml,但在另一个文件夹中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆