如何在 Web API 控制器中获取页面 URL? [英] How to get page URL in Web API controller?

查看:38
本文介绍了如何在 Web API 控制器中获取页面 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

站点 1:test.page.com/News

Site 1: test.page.com/News

站点 2:www.page.com/News

Site 2: www.page.com/News

站点 3:m.site.com/News

Site 3: m.site.com/News

我正在调用 pageapi.

Hi I 'm calling a pageapi.

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

Web Api url:http://www.pageapi.com/api/GetNews

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

How can I get website url(http://m.site.com/) in my Getnews api controller? Which page post my api?

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

I try Url.Request, Request.RequestUri,HttpContext.Current.Request.Path . But I 'didn't get. Always get web api url.

推荐答案

尝试:

HttpContext.Current.Request.UrlReferrer.AbsoluteUri

这篇关于如何在 Web API 控制器中获取页面 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆