简体   繁体   中英

How can I figure out why Views/Home/Index.cshtml Can't be found when debugging with XSP and Monodevelop?

I've been looking for a while now and I'm hoping I'm just missing something small and obvious. Are there Any other Causes that I may have missed for this file not being detected? Most suggestions for this error suggest the file isn't named properly, its path isn't correctly registered, or the location of said file is incorrect.

I don't think its the names, paths or registry. when I run this I can actually debug and hit a breakpoint in my homecontroller before I return the view.

Below is the error I'm getting. I've bolded the path where the file actually exists.

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

~/Views/Home/Index.cshtml
~/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

Below is the stack trace I'm getting

at System.Web.Mvc.ViewResult.FindView (System.Web.Mvc.ControllerContext context) [0x00000] in :0 at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00000] in :0 at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in :0 at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1a.b__17 () [0x00000] in :0 at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter (IResultFilter filter, System.Web.Mvc.ResultExecutingContext preContext, System.Func`1 continuation) [0x00000] in :0 here is what I have for setup.

razorpage/Global.asax.cs

    routes.IgnoreRoute ("{resource}.axd/{*pathInfo}");

    routes.MapRoute (
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

razorpage/Controllers/HomeController.cs

public class HomeController : Controller
{
    public ActionResult Index ()
    {
        return View ();
    }
}

razorpage/Views/Home/Index.cshtml

@model homepagerazor.Controllers.HomeController

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

here is a small snapshot of my folder structure

文件夹快照

Update

In mono there doesn't seem to be specific options for changing your starting page like in visual studio. Playing around with things if I turn of the web.config restrictions I can navigate to a regular html page in the views directory so I know the virtual path is there and correct.

It led me to wonder if the correct view engine is being loaded so I broke into the begginning of the application and checked to make sure the RazorViewEngine is loaded. It is which puts me right back where I started not really know how to track down my issue in returning the home view.

Unfortunately there was more at hand here than a single problem.

First My web config file had two sets of values that had incorrect values set on them.

  • System.Web.MVc, 3.0.0.0 needed to be System.Web.Mvc, 4.0.0.0
  • System.Web.WebPages.Razor, 1.0.0.0 needed to be System.Web.WebPages.Razor, 2.0.0.0
  • I needed to download the package ASP.NET MVC 4. This had all the matching versions of the dlls I cared about.
  • Finally I ended up with a razor syntax error in the index view that also just so happens to give me the exact same lovely error.

As a note on the first two I originally changed it but didn't realize there were quite as many instances of each string as there were I found it useful to do a find and replace on both sets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM