How to forward an HttpRequestMessage to another server

时间秒杀一切 提交于 2019-11-30 18:53:47

You might need to explicitly set the host header on the clone instance. Otherwise you are just copying the original request's host header value across to the clone.

i.e. add the following line to the end of your Clone method:

clone.Headers.Host = new Uri(newUri).Authority;

Also, depending on what you are trying to achieve here, you may also need to handle other issues like cookie domains on the request not matching the new domain you are forwarding to as well as setting the correct domain on any response cookies that are returned.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!