Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 如何更改Razor页面应用程序的启动url路径,使其能够加载特定的.cshtml_Asp.net Core_Razor Pages - Fatal编程技术网

Asp.net core 如何更改Razor页面应用程序的启动url路径,使其能够加载特定的.cshtml

Asp.net core 如何更改Razor页面应用程序的启动url路径,使其能够加载特定的.cshtml,asp.net-core,razor-pages,Asp.net Core,Razor Pages,我想在http://localhost:52856/CRUD/Products/List这样我就可以开始处理List.cshtml文件,而不是在http://localhost:52856 听着,我知道我可以在索引文件上放置一个按钮,这样它就可以重定向到路径或使用导航栏,但我个人不想每次都这样做。只需在文件.cshtml中加载应用程序即可。但是我该怎么做呢?如果您不喜欢我的评论,可以在Index.cshtml.cs中执行以下操作 public IActionResult OnGet() {

我想在
http://localhost:52856/CRUD/Products/List
这样我就可以开始处理
List.cshtml
文件,而不是在
http://localhost:52856


听着,我知道我可以在索引文件上放置一个按钮,这样它就可以重定向到路径或使用导航栏,但我个人不想每次都这样做。只需在
文件.cshtml
中加载应用程序即可。但是我该怎么做呢?

如果您不喜欢我的评论,可以在Index.cshtml.cs中执行以下操作

public IActionResult OnGet()
{
    return new RedirectToPageResult("/CRUD/Product/List");
}

如果您不喜欢我的评论,可以在Index.cshtml.cs中执行以下操作

public IActionResult OnGet()
{
    return new RedirectToPageResult("/CRUD/Product/List");
}

1。将MVC作为一项服务纳入我们的应用程序。 我们可以选择使用另一种称为
AddRazorPagesOptions()
的方法,如下所示:

services.AddMvc().AddRazorPagesOptions(options =>
        {
            options.Conventions.AddPageRoute("/Customer/Index", "");
        });
在这个
AddRazorPagesOptions()
方法中,我们可以设置路由约定和页面的根目录。结果是,为页面设置默认路由


2。删除或重命名页面/Index.cshtml

1。将MVC作为一项服务纳入我们的应用程序。 我们可以选择使用另一种称为
AddRazorPagesOptions()
的方法,如下所示:

services.AddMvc().AddRazorPagesOptions(options =>
        {
            options.Conventions.AddPageRoute("/Customer/Index", "");
        });
在这个
AddRazorPagesOptions()
方法中,我们可以设置路由约定和页面的根目录。结果是,为页面设置默认路由


2。删除或重命名页面/Index.cshtml

请看这是否回答了您的问题?看这回答了你的问题吗?