我正在尝试在本地主机上运行我的asp.net应用程序,但似乎出现了以下错误:
未处理的异常发生在处理请求时。
InvalidOperationException: 未找到视图“Index”。已搜索以下位置: /Views/Web/Index.cshtml /Views/Shared/Index.cshtml /Pages/Shared/Index.cshtml
我将视图放在“Views > Web > Index.cshtml”中,但仍未找到解决此问题的方法。我已经阅读了asp.net文档和其他stackoverflow帖子,但似乎无法解决此问题。
使用: - Visual Studio 2019 - ASP.NET Core 6 - Windows 10
这是我program.cs文件中的代码:
未处理的异常发生在处理请求时。
InvalidOperationException: 未找到视图“Index”。已搜索以下位置: /Views/Web/Index.cshtml /Views/Shared/Index.cshtml /Pages/Shared/Index.cshtml
我将视图放在“Views > Web > Index.cshtml”中,但仍未找到解决此问题的方法。我已经阅读了asp.net文档和其他stackoverflow帖子,但似乎无法解决此问题。
使用: - Visual Studio 2019 - ASP.NET Core 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();