[英]RESTSharp unable to find location header
I have an async Task in C# that returns 我在C#中有一个异步任务,返回
Task<HttpResponseMessage>
Code as follows 代码如下
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Moved);
response.Headers.Location = new Uri(new Shared().ToAbsoluteUrl("~/html/fail.aspx"));
return response;
On codebehind of an ASPX page I have the following code 在ASPX页面的代码背后,我有以下代码
IRestResponse response = client.Execute(request);
if (response.Headers.Any(t => t.Name == "Location"))
{
string location = response.Headers.FirstOrDefault(t => t.Name == "Location").Value.ToString();
}
PROBLEM: I am unable to retrieve the location header value in codebehind. 问题:我无法在代码隐藏中检索位置标头值。 Any ideas? 有任何想法吗?
Add the following: 添加以下内容:
client.FollowRedirects = false;
before this line: 在此行之前:
IRestResponse response = client.Execute(request);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.