asp.net-core-mvc - 如何将主页从索引更改为其他内容?
问题描述
我正在尝试拥有一个与 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 控制器在哪里?是隐含的吗?
解决方案
我使用 .Net core 3.1 并在启动文件中使用它
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllerRoute("default", "
{controller=Home}/{action=Viewer}/{id?}");});
推荐阅读
- javascript - 元视口根本不适用于我的网站
- java - 无法创建 SOAP 连接工厂:未找到提供程序 com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
- laravel - Laravel 手动身份验证不会保持记录
- sql - SQL 查询没有得到相应的列
- ruby - 如何在 Ruby 中最好地抽象类变量
- puppet - 使用查找命令在 puppet 中的多个 hiera 文件中查找相同的键
- python-3.x - skfuzzy C-Mean 中的数据与质心协议
- html - 增加按键角 4 的计数器并减少退格键
- python-3.x - 如何在nx图中获取度数为0的节点?
- android - imageview的android工具提示显示“捏缩放”