如何在ASP.NET Core中设置启动路由

编程入门 行业动态 更新时间:2024-10-26 02:37:12
本文介绍了如何在ASP.NET Core中设置启动路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的ASP.NET核心应用启动路径设置为:

My ASP.NET core app startup route is set as:

/api/values

我想将此启动路线更改为:

I want to change this startup route to be:

/

在文档中查找有关路由约束的大量规范,但我我不确定我是否知道如何设置启动时运行的路由...

Looking through the documentation there is lots of specification on route constraints but I'm not sure I see how to set the route that gets run on startup...

启动时调用了错误的控制器。如果删除控制器(ValueController),则会得到404。在运行时指定在哪里使用此控制器?

It's calling the wrong controller on startup. If I remove the controller (ValueController), I get a 404. Where is it specified to use this controller at runtime?

我在隐藏的launchSettings中看到了希望。 json但正在编辑

I'm seeing hope in the hidden launchSettings.json but editing

localhost:5000/api/value

localhost:5000/

没有帮助

推荐答案

Adam Weitzman是正确的,但您也可以使用Visual Studio的GUI进行切换。

Adam Weitzman is right, but you can also switch it using Visual Studio's GUI.

  • 右键单击项目在解决方案资源管理器中
  • 单击属性
  • 转到调试选项卡
  • 检查启动URL 复选框并设置所需的URL。将文本框留空以启动根URL
  • Right-click on project in Solution Explorer
  • Click Properties
  • Go to Debug tab
  • Check the Launch URL checkbox and set the URL you want. Leave the text box empty to launch the root URL
  • 更多推荐

    如何在ASP.NET Core中设置启动路由

    本文发布于:2023-11-17 05:13:35,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1608949.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:路由   如何在   NET   ASP   Core

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!