url - 如何在 Web API Controller 中获取页面 URL?

标签 url asp.net-web-api

关闭。这个问题需要details or clarity .它目前不接受答案。












想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.

6年前关闭。




Improve this question




站点 1:test.page.com/News

站点 2:www.page.com/News

站点 3:m.site.com/News

嗨,我正在调用 pageapi。

Web Api 网址:http://www.pageapi.com/api/GetNews

如何在我的 Getnews api Controller 中获取网站 url( http://m.site.com/ )?哪个页面发布了我的api?

我尝试 Url.Request, Request.RequestUri,HttpContext.Current.Request.Path 。但我没有得到。始终获取 web api url。

最佳答案

尝试:

HttpContext.Current.Request.UrlReferrer.AbsoluteUri

关于url - 如何在 Web API Controller 中获取页面 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28368328/

相关文章:

asp.net - 具有不带.aspx扩展名的URL

c# - 从 IOwinContext 获取路由模板

visual-studio - 如何从 Visual Studio ASP.NET Web API 应用程序禁用 Docker?

php - 使用 .htaccess 隐藏 URL 关键参数

.htaccess - URL 重写在 Wamp 服务器上不起作用

asp.net-web-api - 重新使用 jwt 从另一个 API 调用 API

c# - JSON 对象创建 PushStreamContent

c# - ASP.net Web Api 版本控制

cocoa - NSURL 的参数字符串使用 ';' 与 '&' 发生混淆

php - 获取基本路径/URL