找不到视图“索引”

时间:2019-07-03 13:51:58

标签: c# asp.net-core asp.net-core-mvc

我正在使用.NetCore创建Web应用程序。完成编码并运行程序后,以下错误标志将帮助我。 我添加了一些布局文件 前端是启动文件

输出工具栏 当我运行应用程序时,它显示如下:

Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/2.0 GET https://localhost:44349/admin/products/Index  
Microsoft.AspNetCore.Routing.EndpointMiddleware:Information: Executing endpoint 'Ghost.Areas.Admin.Controllers.Products.Index (Ghost)'
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {area = "Admin", action = "Index", controller = "Products"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Index() on controller Ghost.Areas.Admin.Controllers.Products (Ghost).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method Ghost.Areas.Admin.Controllers.Products.Index (Ghost) - Validation state: Valid
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.2.5\System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action method Ghost.Areas.Admin.Controllers.Products.Index (Ghost), returned result Microsoft.AspNetCore.Mvc.ViewResult in 5.1894ms.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor:Information: Executing ViewResult, running view Index.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor:Error: The view 'Index' was not found. Searched locations: /Areas/Admin/Views/Products/Index.cshtml, /Areas/Admin/Views/Shared/Index.cshtml, /Views/Shared/Index.cshtml, /Pages/Shared/Index.cshtml
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action Ghost.Areas.Admin.Controllers.Products.Index (Ghost) in 29.4028ms
Microsoft.AspNetCore.Routing.EndpointMiddleware:Information: Executed endpoint 'Ghost.Areas.Admin.Controllers.Products.Index (Ghost)'
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.5\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.5\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Error: An unhandled exception has occurred while executing the request.

System.InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Areas/Admin/Views/Products/Index.cshtml
/Areas/Admin/Views/Shared/Index.cshtml
/Views/Shared/Index.cshtml
/Pages/Shared/Index.cshtml
   at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)

Index.cshtml文件 这是显示丢失的文件 路径是Areas / Admin / Controllers / Views / Product / Index.cshtml

@{
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    ViewBag.Title = "Products Index";

}

<div class="container-fluid">
    <!-- Page Content -->

    <div class="row">
        <div class="col-md-12">
            <div class="white-box">
                <h3 class="box-title">PRODUCTS</h3>
                <a class="btn btn-success" href="/Admin/Products/Create"><span class="btn btn-label"><i class="fa fa-check"></i></span>Add New Product</a>
            </div>

_AdminLayout.cshtml文件

<link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/sidebar-nav.min.css" rel="stylesheet" />
    <link href="~/css/animate.css" rel="stylesheet" />
    <link href="~/css/default.css" rel="stylesheet" />
    <link href="~/css/style.css" rel="stylesheet" />
</head>
<body class="fix-header fix-sidebar">
    <div id="wrapper">
        @Html.Partial("AdminPartials/_TopMenu")
        @Html.Partial("AdminPartials/_Sidebar")
        <div id="page-wrapper" style="min-height:600px">
            <div class="container-fluid">
                @RenderBody()
                <hr />
                <footer class="footer text-center">© @DateTime.Now.Year | Powered by Techguy</footer>
            </div>
        </div>
    </div>

    @RenderSection("scripts", required: false)

_FrontendLayout.cshtml 路径:视图/共享               @ ViewBag.Title

    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/sidebar-nav.min.css" rel="stylesheet" />
    <link href="~/css/animate.css" rel="stylesheet" />
    <link href="~/css/default.css" rel="stylesheet" />
    <link href="~/css/style.css" rel="stylesheet" />
</head>
<body class="fix-header">
    <div id="wrapper">

        <div id="page-wrapper" style="min-height:600px">
            <div class="container-fluid">
                @RenderBody()
                <hr />
                <footer class="footer text-center">© @DateTime.Now.Year | Powered by Techguy</footer>
            </div>
        </div>
    </div>

    @RenderSection("scripts", required: false)
        </div>
    </div>

0 个答案:

没有答案