基本地址+ HttpClient中的相对地址......什么是完整地址? [英] base address + relative address in HttpClient... what is full address?

查看:136
本文介绍了基本地址+ HttpClient中的相对地址......什么是完整地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个HttpClient发出这样的请求:



< pre class ="prettyprint"> string APIBaseAddress = ConfigurationManager.AppSettings [" APIBaseAddress"];
string APIRelativeAddress = ConfigurationManager.AppSettings [" APIRelativeAddress"];

var client = new HttpClient();
client.BaseAddress = new Uri(APIBaseAddress);

...

var securityTokenRequest = new HttpRequestMessage(HttpMethod.Post,$" {APIRelativeAddress} / token");

...

client.SendAsync(securityTokenRequest);




$


它将APIBaseAddress作为基地址,将{APIRelativeAddress} / token作为相对于基地址的特定地址。



我想知道的是:完整的地址最终看起来像什么?它只是APIBaseAddress / {APIRelativeAddress} / token吗?
$


有没有办法检查HttpClient对象以查看完整对象是什么?

解决方案

Hello gib898,


>>我想知道的是:完整的地址最终看起来像什么?有没有办法检查HttpClient对象以查看完整对象是什么


当我想看到http请求标题时我就知道了通常使用第三方工具来捕获http请求。它将为我提供整个请求消息进行调试。您可以尝试使用
fidder 或其他。


最诚挚的问候,


Neil Hu


Hello,

I have an HttpClient that's sending off a request like this:

            string APIBaseAddress = ConfigurationManager.AppSettings["APIBaseAddress"];
            string APIRelativeAddress = ConfigurationManager.AppSettings["APIRelativeAddress"];

            var client = new HttpClient();
            client.BaseAddress = new Uri(APIBaseAddress);

...

	var securityTokenRequest = new HttpRequestMessage(HttpMethod.Post, $"{APIRelativeAddress}/token");

...

client.SendAsync(securityTokenRequest);




It takes APIBaseAddress as the base address and {APIRelativeAddress}/token as the specific address relative to the base address.

What I'm wondering is: what does the full address end up looking like? Is it just APIBaseAddress/{APIRelativeAddress}/token?

Is there any way to check the HttpClient object to see what the full object is?

解决方案

Hello gib898,

>>What I'm wondering is: what does the full address end up looking like? Is there any way to check the HttpClient object to see what the full object is

When I want to see http request header I usually use third party tools to capture http request. it will provide entire request message for me to debug. you could try to use fidder or others.

Best Regards,

Neil Hu


这篇关于基本地址+ HttpClient中的相对地址......什么是完整地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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