C
C#2y ago
bookuha

❔ 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
bookuha
bookuhaOP2y ago
well works fine when in the same project/assembly but no idea how to make it fetch views from another
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server