目前,我们正在向 asp.net 应用程序添加 asp-net web api 支持。但是,当使用任何路径请求控制器上的操作时,AppRelativeCurrentExecutionFilePath 始终设置为“~/”并导致 400 错误。使用此处可用的路由调试器确认 AppRelativeCurrentExecutionFilePath 始终不正确,无论 url 是什么。
例如,以下所有 url 访问,将 AppRelativeCurrentExecutionFilePath 设置为“~/”
http://localhost:1521/Testclient/apitest/values/get
http://localhost:1521/Testclient/apitest/values/get/1
即使路由表具有必需的条目,路由调试器也会显示上述 url 的失败/不匹配。
已禁用所有 Application_BeginRequest/VPP/module/http 处理程序以及任何可能导致路由受到影响但仍遇到相同问题的内容。还有其他可能的方法可以调试吗?
Update1:通过处理 global.asax 中的 Application_BeginRequest() 检查了 application.Request.AppRelativeCurrentExecutionFilePath,即使它看起来是错误的。