【问题标题】:How to change home page from Index to something else?如何将主页从索引更改为其他内容?
【发布时间】:2019-09-03 06:42:33
【问题描述】:

我正在尝试创建一个不同于 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 控制器在哪里?是隐含的吗?

【问题讨论】:

  • 您想将哪个视图设置为默认视图,而不是索引视图?观众?
  • 是的。我希望登陆页面是 http(s)://localhost:5000/ === http(s)://localhost:5000/Viewer
  • 设置routes.MapRoute("default", "{controller=Home}/{action=Viewer}");后不工作?

标签: asp.net-core-mvc website-homepage


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2013-09-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    • 2014-07-05
    • 1970-01-01
    相关资源
    最近更新 更多