如何使用.NET Core 2中的Razor Pages更改起始页? [英] How to change starting page, using Razor Pages in .NET Core 2?

查看:94
本文介绍了如何使用.NET Core 2中的Razor Pages更改起始页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将起始页面设置为/Members/Index.

I wanted to set my starting page to /Members/Index.

使用MVC时,我将其配置如下:

When I was using MVC, I configured it as following:

app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Members}/{action=Index}/{id?}");
            });

但是现在我正在尝试新的Razor Pages方法,现在Member是文件夹,而Index是Razor Page. 如何将文件夹中的此页面设置为起始页面?

But now I'm trying new Razor Pages approach, and now Members is folder and Index is Razor Page. How to set this page in folder as starting one?

我可以在根目录中添加索引页面并在其中进行重定向,但是我正在寻找更清洁的东西.

I can add Index page in root directory and make redirect there, but I was looking for something cleaner.

推荐答案

出于测试目的,您可以通过转到Web项目的属性"窗口并选择调试"选项卡来更改起始页.在启动浏览器"行上,输入起始路径

For testing purposes you can change the start page by going to the Properties window for the web project and select the Debug tab. On the 'Launch browser' line enter the starting path

这篇关于如何使用.NET Core 2中的Razor Pages更改起始页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆