从WebService调用获取响应头?

时间:2020-12-01 14:05:21

Is there a way to get the responde headers from a web service call on .net?

有没有办法从.net上的Web服务调用获取响应标头?

1 个解决方案

#1


2  

Write the following code from inside of the WebMethod (Web Service Method)

从WebMethod(Web服务方法)内部编写以下代码

You may use a for loop to iterate through all the keys value pairs in the Header

您可以使用for循环遍历Header中的所有键值对

int Count = HttpContext.Current.Request.Headers.Count;
for (int i = 0; i < Count; i++)
{
    string key = HttpContext.Current.Request.Headers.GetKey(i);
    string keyValue = HttpContext.Current.Request.Headers.Get(i);
    //Do something
}

#1


2  

Write the following code from inside of the WebMethod (Web Service Method)

从WebMethod(Web服务方法)内部编写以下代码

You may use a for loop to iterate through all the keys value pairs in the Header

您可以使用for循环遍历Header中的所有键值对

int Count = HttpContext.Current.Request.Headers.Count;
for (int i = 0; i < Count; i++)
{
    string key = HttpContext.Current.Request.Headers.GetKey(i);
    string keyValue = HttpContext.Current.Request.Headers.Get(i);
    //Do something
}