문제

내 사이트에 다음 코드가 있습니다. 거의 빈 ASP.NET MVC 프로젝트의 마스터 페이지입니다.

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

Feeds라는 Views 폴더에 폴더 이상의 것을 추가하지 않았습니다. 피드 폴더에는 두 개의 뷰가 있습니다. feedlist.aspx 및 monitoredfeeds.aspx. 또한 다음과 같이 다음 코드를 HomeController에 추가했습니다.

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

그래도 내가 무엇을하든 페이지에 대한 링크를 클릭 할 때마다 다음 오류가 표시됩니다.

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.<InvokeActionResultWithFilters>b__10() +39
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +385
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionResultWithFilters>b__12() +61
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ActionResult actionResult, IList`1 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 

내가 뭔가를 놓쳤습니까? 어딘가에 피드 폴더를 추가해야합니까? 피드는 링크에 "집"이있는 곳으로 가야합니까? 나는 심지어 그것을 시도했지만 여전히 오류를 얻었습니다.

감사.

도움이 되었습니까?

해결책

FeedScontroller.cs를 생성하고 해당 컨트롤러로 이동하십시오

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

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

그런 다음 피드 컨트롤러를 사용하려면이 문제를 해결하십시오

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

다른 팁

컨트롤러를 "홈"이라고하므로 뷰는보기/피드가 아닌보기/홈 폴더에 있어야합니다.

오류 메시지는 ~/views/home/feedlist.aspx 및 ~/views/home/feedlist.ascx를 검색하고 있음을 분명히 나타냅니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top