重定向C#后如何获取URL?

时间:2014-05-05 14:51:29

标签: c# windows-phone

HttpClient client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = true }) { };
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("ContentType", "audio/mpeg");
request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36");
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Host", "fsa.zedge.net");
request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
request.Headers.Add("Accept-Language", "en-US,en;q=0.8,vi;q=0.6");
request.Headers.Add("Cache-Control", "max-age=0");
request.Headers.Add("Connection", "keep-alive");

HttpResponseMessage response = await client.GetAsync(new Uri(url,UriKind.Absolute));
response.EnsureSuccessStatusCode();
string responseUri = response.RequestMessage.RequestUri.AbsoluteUri;
  

发生了'System.Net.Http.HttpRequestException'类型的异常   在System.Net.Http.DLL中但未在用户代码中处理

     

附加信息:响应状态代码未指示   成功: 403(禁止)

我有一个网址,但是当我得到它时,它会移向另一个网址,每次网址被重定向到网址时,它都会有所不同。每次过期时,此URL工作会话。所以现在每次我得到一个新的URL,它只是告知会话失败

0 个答案:

没有答案