admin管理员组文章数量:1418870
I have a ASP.NET Web API controller which inherits from a custom class which in turn inherits from System.Web.Http.ApiController
. In one of my actions, I return a URL to another action of the same controller by using Url.Link()
.
Recently, we introduced a new version of the application in .NET 8. But we keep the legacy app and forward the requests to it by using a reverse proxy (YARP in our case). During this, we changed the port for the legacy app in local IIS to something like 12345
. The new app is hosted on a Docker container and the routing is done by using Ingress.
This change, however, adds the port number to the host when the request is received by the legacy app. This causes a CORS policy error when the client tries to call the returned URL.
So, I'm trying to figure out where I can fix the host for the returned URL.
What I've already tried
- Adding
proxy_set_header X-Forwarded-Host
to nginx configuration. It didn't seem to make any change. - Setting
HttpContext.Current.Request.ServerVariables["HTTP_HOST"]
inApplication_BeginRequest
inGlobal.asax.cs
(in legacy app). When I debug and step into my action, I can see thatRequest.Headers.Host
is changed accordingly, butRequest.RequestUri
still showing the old host (with port) and so doesUrl.Link()
.
Anything I might have missed? Or any other subtle solution?
本文标签: UrlLink() in ASPNET app behind reverse proxy returns wrong hostportStack Overflow
版权声明:本文标题:Url.Link() in ASP.NET app behind reverse proxy returns wrong hostport - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745300283a2652331.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论