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.vbhtmlBelow 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.
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.