C# 如何使asp.net核心mvc/razor页面混合应用程序中的默认页面使用mvc默认页面&x27;主页/索引';页

C# 如何使asp.net核心mvc/razor页面混合应用程序中的默认页面使用mvc默认页面&x27;主页/索引';页,c#,asp.net-core,asp.net-core-mvc,razor-pages,C#,Asp.net Core,Asp.net Core Mvc,Razor Pages,我有一个asp.NETMVC核心应用程序,我将mvc和Razor页面组合在一起 当前,当我加载应用程序时,它会加载索引页面 我正在尝试创建初始页面()以从mvc呈现视图 我怎样才能做到这一点 这是我在startup.cs文件中的代码: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration;

我有一个asp.NETMVC核心应用程序,我将mvc和Razor页面组合在一起

当前,当我加载应用程序时,它会加载索引页面

我正在尝试创建初始页面()以从mvc呈现视图

我怎样才能做到这一点

这是我在startup.cs文件中的代码:

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddRazorPages();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

        }
    }
主控制器:

public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
公共类HomeController:控制器
{
专用只读ILogger\u记录器;
公共家庭控制器(ILogger记录器)
{
_记录器=记录器;
}
公共IActionResult索引()
{
返回视图();
}
公共IActionResult隐私()
{
返回视图();
}
[ResponseCache(持续时间=0,位置=ResponseCache位置。无,NoStore=true)]
公共IActionResult错误()
{
返回视图(新的ErrorViewModel{RequestId=Activity.Current?.Id??HttpContext.TraceIdentifier});
}
}

为什么不直接删除/索引页?为什么不直接删除/索引页?