无法找到位置标头
本文关键字:位置 | 更新日期: 2023-09-27 18:15:33
我在c#中有一个async Task返回
Task<HttpResponseMessage>
代码如下
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Moved);
response.Headers.Location = new Uri(new Shared().ToAbsoluteUrl("~/html/fail.aspx"));
return response;
在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();
}
问题:我无法在代码隐藏中检索位置标头值。什么好主意吗?
添加以下内容:
client.FollowRedirects = false;
行前:
IRestResponse response = client.Execute(request);