[英]asp.net mvc get absolute url (behind proxy)
user --> internet --> server1 (iis proxy) --> server2 (hosting the website)
I'm trying to get the absolute url. 我正在尝试获取绝对网址。
The code below has worked without any problem when we were not using a proxy: 当我们不使用代理时,以下代码可以正常工作:
string fullUrl = Url.Action("Bar", "Foo", new RouteValueDictionary(new { id = pid, search = search }), Request.Url.Scheme);
string fullUrlEncoded = HttpUtility.UrlEncode(fullUrl);
However now instead I receive this absolute url with internal ip: 但是现在我收到带有内部ip的绝对URL:
http://192.168.0.3/Foo/Bar/5
How can this be solved? 如何解决呢?
I ended up by hardcoding the url in the appsettings and adding it to the url as suggested by Chris Pratt. 最后,我按照Chris Pratt的建议在appsettings中对网址进行了硬编码,然后将其添加到了网址中。 I could not use any X-Forwarded-For header, it was enabled but I didn't receive that information, so could not use it. 我无法使用任何X-Forwarded-For标头,但已启用该标头,但未收到该信息,因此无法使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.