Reputation: 544
I created a .NET Core 3.1 ASPNET project. By default, the startup page us the Home Controller/Index page.
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
But I want to make a Login Page, so I Created a New Controller with a new Action and I passed on the parameter, but instead of ONLY render the Login Page, it renders inside of the "@RenderBody()" from the layout project. On .NET MVC5 it only rendered the page that I set. I already tried with :
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
And it's the same thing. The login page it's not rendered apart of the layout
Upvotes: 0
Views: 1352
Reputation: 20354
This has nothing to do with routing.
If you look in your Views folder, there will be a file called _ViewStart.cshtml, containing this code:
@{
Layout = "_Layout";
}
_ViewStart.cshtml runs for every view, so by default it sets the layout page to _Layout.cshtml.
There are 2 options:
Layout
needs to be explicitly set in each view.Layout
to null
.Upvotes: 2