。net核心,如何使用额外的前斜杠处理路由

问题描述 投票:0回答:1

我需要处理以下形式的传入请求://ohif/study/1.1/series注意前面的斜杠

我的控制器签名是:

[Route("ohif/study/{studyUid}/series")]
[HttpGet]
public IActionResult GetStudy(string studyUid)

如果我将传入请求修改为/ohif/study/1.1/series,它将正常工作

但是,当我使用//ohif/study/1.1/series时,路由未命中

此外,我还尝试过:[Route(“ / ohif / study / {studyUid} / series”)]和[Route(“ // ohif / study / {studyUid} / series”)]

均失败。不幸的是,我无法更改传入请求,因为它是来自外部应用程序的。有一些技巧可以处理这条路线吗?我正在.NET Core 3.0中工作。

更新说明:我已激活日志记录,看到asp.net核心正在分析路由,我收到消息:找不到请求路径“ //ohif/study/1.1/series”的候选对象记录器Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware

asp.net model-view-controller asp.net-core-mvc asp.net-core-2.0
1个回答
0
投票

[在Web服务器级别重写URL,例如对于IIS,可以使用URL重写模块自动将//ohif/study/1.1/series重定向到/ohif/study/1.1/series。这不是您的应用程序的工作。

© www.soinside.com 2019 - 2024. All rights reserved.