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

时间:2017-02-20 16:49:35

标签: c# .net routing asp.net-core

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

/api/values

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

/

查看文档有很多关于路由约束的规范,但我不确定如何设置在启动时运行的路由...

它在启动时调用错误的控制器。如果我删除控制器(ValueController),我得到一个404.它指定在运行时使用该控制器在哪里?

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

http://localhost:5000/api/value

http://localhost:5000/

无效

2 个答案:

答案 0 :(得分:10)

Adam Weitzman是对的,但您也可以使用Visual Studio的GUI切换它。

  1. 在解决方案资源管理器中右键单击项目
  2. 单击“属性”
  3. 转到“调试”标签
  4. 选中#This thing modifies the path from sys import path #This gets our user directory from os import environ #add module_1's location to path path.append(environ['USERPROFILE'] + "\\Documents\\Project_1") #import it now import module_1 复选框并设置所需的网址。将文本框保留为空以启动根URL
  5. Launch URL setting

答案 1 :(得分:1)

它位于Properties/launchSettings.json

要改变的领域是:

profiles.IISExpress.launchUrl