首页 > 解决方案 > 如何将主页从索引更改为其他内容?

问题描述

我正在尝试拥有一个与 Index.cshtml 不同的主页

http(s)://localhost:5000==> 目前对应http(s)://localhost:5000/Index

在互联网上发现围绕相同概念的变体:

在 Startup.Configure 从这里改变

app.UseMvc();

对此

app.UseMvc(routes =>
{
   routes.MapRoute("default", "{controller=Home}/{action=Viewer}");
});

顺便说一句:Home 控制器在哪里?是隐含的吗?

标签: asp.net-core-mvcwebsite-homepage

解决方案


我使用 .Net core 3.1 并在启动文件中使用它

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

推荐阅读