❔ Locating views in another Assembly
I have my Program in project Web, and Views in project Core
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(x => x.AllowSynchronousIO = true);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddControllersWithViews()
.AddApplicationPart(typeof(Faction).Assembly); // Add controllers from another assembly
var app = builder.Build();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.MapRazorPages();
app.Run();
Thats how I add controllers and view.
Corresponding views are in the same folder as controller (on the pic)
But when I match my controller, it says there is no such view:
An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Stats.cshtml' was not found. The following locations were searched:
/Stats.cshtml
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable<string> originalLocations)2 Replies