IIS express doesn’t show index.cshtml in one folder but in other it shows

I’m developing an ASP.NET MVC 5 application with C# and .Net Framework 4.7.

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();
        }
    }
}

I have right clicked at Index method and select Add View.... It has created a new cshtml file in folder .ViewsReports called Index.cshtml with this content:

@{
    ViewBag.Title = Resources.ReportsIndexTitle;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Styles
{
    <link href="~/css/tables.css" rel="nofollow noreferrer noopener" rel="stylesheet" />
    <link href="~/css/jquery-ui.css" rel="nofollow noreferrer noopener" 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")

But I have added a breakpoint at ReportsController.Index method and it doesn’t stop.

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.

What’s going on?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

But I have added a breakpoint at ReportsController.Index method and it
doesn’t stop.

Since it’s deployed in IIS, just setting an breakpoint won’t enough, you will have to attach the w3wp worker process to the debugger in-order to debug.

How to attach an external process to VS debugger?

See MSDN for more information.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x