【发布时间】:2020-10-22 22:09:48
【问题描述】:
这是一个关于为什么会发生这种情况的非常简单的问题。
首先,我有一个 .net core 2.1 项目,我需要 3 个额外的端点,所以这是我的代码:
app.Map("/h1", handle1);
app.Map("/h1/h2", handle2);
app.Map("/h1/h3", handle3);
在配置方法中。 handle1、handl2 和 handle3 是在 localhost:port/h1、localhost:port/h1/h2 和 localhost:port/h1/h3 上编写不同内容的自定义方法。
但这不起作用,因为我在 localhost:port/h1/h2 得到的结果与其他两个相同,所以 localhost:port/h1 是正确的,但 localhost:port/h1/h2 和 localhost:port/ h1/h3 显示 localhost:port/h1 这是不正确的。
我已经尝试了一些东西,这是一种工作:
app.Map("/h1", handle1);
app.Map("/h/h2", handle2);
app.Map("/h/h3", handle3);
问题是为什么?以及如何使 localhost:port/h1 和 localhost:port/h1/h2 和 localhost:port/h1/h3 工作?
更新:
我试过了,它有效,但我不明白为什么
app.Map("/h1/h2", handle2);
app.Map("/h1/h3", handle3);
app.Map("/h1", handle1);
【问题讨论】:
标签: asp.net-core-2.1