[英]Change default page folder on Asp net core Mvc 2.2
is there a way to change the default directory of ".cshtml" files from "Pages" folder to a custom one?有没有办法将“.cshtml”文件的默认目录从“Pages”文件夹更改为自定义目录?
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/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.