This setting by default (i.e., the RootDirectory
is configured for the folder /Pages
) and configures your pages are inside the folder /Pages
and follows a convention where the subfolders have the name of the route to load the pages. If you change the index
for the way Pages/Teste
in the browser should also be named because it follows this directory naming convention, example:
http://localhost/teste/index
for this page to be loaded. If you want to create a route in addition then do as in the example below:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddRazorPagesOptions(options =>
{
// faz a rota para a página padrão
options.Conventions.AddPageRoute("/Teste/index", "");
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
and in the browser:
http://localhost
following the same as the standard configuration, but otherwise arranged.
And if I want to change the name of this Pages folder, how do I work properly?
If you change the folder name you also need to configure the default settings as follows:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddRazorPagesOptions(options =>
{
//configurando o nome da pasta root padrão
options.RootDirectory = "/Pages1";
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
where options.RootDirectory
enables you to configure the default folder name of your pages.
All two changes without a context and perhaps even without need will not bring any benefit, try working with the standard mode that will simplify your development environment.
References
Samuel, post the class code
Startup
– Jéf Bueno