Hello,
I am creating an ASP.NET Core Razor Pages website, where the planned layout of the website will be the following navigation menu structure: - Home | About Us | Services | Login | Contact Us. I have developed the Login webpage and. At present, when a user the builds the solution, it loads to a Login webpage. The user will then use a login & password to login to the Product Services webpage. I would like to change the default landing page so that the solution build loads to a "Home" (the default homepage) instead of the Login webpage.
In the Pages Folder, I created a Home Folder which contain the razor pages Index.cshtml and Index.cshtml.cs. In the Index.cshtml, I changed line 1 from:-
to
@page "/Homepage"
and in the Startup.cs file, I added the followed code:-
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddRazorPagesOptions(options =>
{
options.Conventions.AddPageRoute("/Home/Index", "");
});
}
In the _Layout.cshtml file, the following code is found: -
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-page="/Index" class="navbar-brand">Goods Store</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-page="/Login/Index">Login</a></li>
<li><a asp-page="/About">About</a></li>
<li><a asp-page="/Service 1/Index">Service 1</a></li>
<li><a asp-page="/Service 2/Index">Service 2</a></li>
</ul>
</div>
</div>
</nav>
</body>
However, when I build the solution, and I enter the Home url address: https://localhost:44370/Home/Index
, I see the following error message:
This localhost page can’t be foundNo webpage was found for the web address: https://localhost:44370/Home/Index
HTTP ERROR 404
Any assistance will be greatly appreciated.