vote up 0 vote down
star

I have the following code in my Site.Master page of an almost empty ASP.NET MVC Project.

<li>
    <%= Html.ActionLink("Home", "Index", "Home")%>
</li>
<li>
    <%= Html.ActionLink("Feed List", "FeedList", "Home")%>
</li>
<li>
    <%= Html.ActionLink("Monitored Feeds", "MonitoredFeeds", "Home")%>
</li>
<li>
    <%= Html.ActionLink("About", "About", "Home")%>
</li>

I haven't added anything more than a Folder to the Views Folder called Feeds. In the Feeds folder I have two Views; FeedList.aspx and MonitoredFeeds.aspx. I also added the following code to the HomeController as below.

    [HandleError]
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewData["Title"] = "The Reporter";
        ViewData["Message"] = "Welcome to The Reporter.";
        return View();
    }

    public ActionResult About()
    {
        ViewData["Title"] = "About Page";
        return View();
    }

    public ActionResult FeedList()
    {
        ViewData["Title"] = "Feed List";
        return View();
    }

    public ActionResult MonitoredFeeds()
    {
        ViewData["Title"] = "Monitored Feeds";
        return View();
    }
}

No matter what I do though, whenever I click on the links to the pages, the following error is displayed.

Server Error in '/' Application.

The view 'FeedList' or its master could not be found. The following locations were searched: ~/Views/Home/FeedList.aspx ~/Views/Home/FeedList.ascx ~/Views/Shared/FeedList.aspx ~/Views/Shared/FeedList.ascx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The view 'FeedList' or its master could not be found. The following locations were searched: ~/Views/Home/FeedList.aspx ~/Views/Home/FeedList.ascx ~/Views/Shared/FeedList.aspx ~/Views/Shared/FeedList.ascx

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: The view 'FeedList' or its master could not be found. The following locations were searched: ~/Views/Home/FeedList.aspx ~/Views/Home/FeedList.ascx ~/Views/Shared/FeedList.aspx ~/Views/Shared/FeedList.ascx] System.Web.Mvc.ViewResult.FindView(ControllerContext context) +493 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +199 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ActionResult actionResult) +105 System.Web.Mvc.<>c__DisplayClass13.b__10() +39 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +385 System.Web.Mvc.<>c__DisplayClass15.<InvokeActionResultWithFilters>b__12() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ActionResult actionResult, IList1 filters) +386 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +736 System.Web.Mvc.Controller.ExecuteCore() +180 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +96 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +36 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +377 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +71 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +36 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

Have I missed something? Do I need to add the Feeds folder somewhere? Does Feeds need to go where I have "Home" listed in the links? I've even tried that and still got the error.

Thanks.

flag
add comment

2 Answers:

vote up 4 vote down
check

Create a FeedsController.cs and move these to that controller

public ActionResult FeedList()
{
    ViewData["Title"] = "Feed List";
    return View();
}

public ActionResult MonitoredFeeds()
{
    ViewData["Title"] = "Monitored Feeds";
    return View();
}

Then fix these to use the Feeds controller

<li>
    <%= Html.ActionLink("Feed List", "FeedList", "Feeds")%>
</li>
<li>
    <%= Html.ActionLink("Monitored Feeds", "MonitoredFeeds", "Feeds")%>
</li>
link|flag
Yes, this is actually the best solution because feeds have nothing to do with the HomeController, and I think it's exactly what Adron was trying to achieve. +1 – sork Nov 27 at 13:56
Actually I looked back at this and this is the best solution, it is what I was trying to achieve, but I clicked the other answer... :( Both are valid answers though. – Adron Apr 30 at 22:46
add comment
vote up 7 vote down

Your controller is called "Home", therefore your views should be in the Views/Home folder, not in Views/Feeds.

The error message clearly states that it is searching for ~/Views/Home/FeedList.aspx and ~/Views/Home/FeedList.ascx

link|flag
add comment

Your Answer:

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.