【发布时间】:2019-02-19 15:33:31
【问题描述】:
我有一个运行小型 Web API 的 .NET Core 应用程序。
以下路线没有任何问题。
工作 HTTP 路由
[HttpGet("api/voting/{id:int}")]
[Produces("application/json")]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(Voting))]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] int id)
{
// Left out for the sake of brevity ...
}
非工作 HTTP 路由 (仅在 Azure 上)
[HttpGet("api/voting/{slug:regex(\\w+)}/full")]
[MapToApiVersion("1.0")]
[Produces("application/json")]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(Voting))]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetBySlugAsync([FromRoute] string slug)
{
// Left out for the sake of brevity ...
}
Azure 中的错误消息
疑难解答
-
如果我在本地环境中运行它,一切都运行良好,只有在 Azure 中运行时才会出现问题。
-
在
Requested URL中附加了端口80,我不太明白,因为我只通过https 与服务通信。莫非是正则表达式干扰了端口后缀? -
Physical Path出于某种原因将路由附加到wwwroot目录。这是否意味着无法正确解析路由?提前致谢!
【问题讨论】:
标签: azure iis .net-core asp.net-mvc-routing asp.net-core-webapi