【发布时间】:2019-09-23 14:03:35
【问题描述】:
我正在尝试更改http://localhost:5001/api/values 路由,但程序卡在此网址。
我阅读了这个解决方案
How to change the default controller and action in ASP.NET Core API?
How to redirect root to swagger in Asp.Net Core 2.x?
https://medium.com/quick-code/routing-in-asp-net-core-c433bff3f1a4
每个人都写同样的东西,但不适合我。
我的launchSetting.json 文件是
{ "$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54650",
"sslPort": 44382
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ShoppingBasketAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
我试图改变app.UseMvc();
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2
这也不行。api/values 来自哪里?我想不通。
我的控制器属性路由是
[Route("api/[controller]/[action]")]
【问题讨论】:
标签: c# asp.net asp.net-core asp.net-core-webapi .net-core-2.2