相关疑难解决方法(0)

尽管索引存在,但找不到视图“索引” - ASP.NET Core 6 MVC

我试图在本地主机上运行我的 asp.net 应用程序,但似乎出现以下错误:

处理请求时发生未处理的异常。

InvalidOperationException:未找到视图“索引”。搜索了以下位置:
/Views/Web/Index.cshtml
/Views/Shared/Index.cshtml
/Pages/Shared/Index.cshtml

我的观点位于Views > Web > Index.cshtml,尽管我仍然没有找到解决此问题的方法。我已经阅读了 asp.net 文档和其他 stackoverflow 帖子。似乎无法解决问题。

使用:

  • 视觉工作室 2019
  • ASP.NET 核心 6
  • Windows 10

这是我的program.cs文件中的代码

    using UploadExcel.Context;
    using UploadExcel.Service;
    
    var builder = WebApplication.CreateBuilder(args);
    
    // Add services to the container.
    builder.Services.AddRazorPages();
    builder.Services.AddDbContext<DatabaseContext>();
    builder.Services.AddScoped<IWebService, WebService>();
    
    var app = builder.Build();
    
    // Configure the HTTP request pipeline.
    
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Error");
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    
    app.UseRouting();
    
    app.UseAuthorization();
    
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Web}/{action=Index}/{id?}");
    });
    
    app.MapRazorPages();
    
    app.Run();
Run Code Online (Sandbox Code Playgroud)

asp.net-core-mvc asp.net-core .net-6.0

8
推荐指数
3
解决办法
2万
查看次数

标签 统计

.net-6.0 ×1

asp.net-core ×1

asp.net-core-mvc ×1