is there a way to change the default directory of ".cshtml" files from "Pages" folder to a custom one?
I tried with the following code but it doesn't seem to work
services.Configure<RazorViewEngineOptions>(o =>
{
o.ViewLocationFormats.Clear();
o.ViewLocationFormats.Add("/Test/{0}" + RazorViewEngine.ViewExtension);
});
Thanks in advance.
The following worked for me
services.AddMvc().AddRazorPagesOptions(options =>
{
options.RootDirectory = "/MyPages";
}
public void ConfigureServices(IServiceCollection services) { services.AddMvc().WithRazorPagesRoot("/MyPages"); } For details folow the link https://www.talkingdotnet.com/change-asp-net-core-razor-pages-default-directory-name/ public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddRazorPagesOptions(options => { options.Conventions.AddPageRoute("/Employees/Index", ""); }); } For more follow the links https://exceptionnotfound.net/setting-a-custom-default-page-in-asp-net-core-razor-pages/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.