c# - Getting 403 Forbidden for the same request to server in second time
问题描述
I using HttpClient object make an http call to retrieve audio content of file. Somehow same request works for first time but when i seek the content and make the new request with same set of headers i am getting 403 Forbidden error.
I just don't understand what exactly causing the error. I tried to set User-agent in DefaultRequestHeaders but nothing is working.
await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
Response Header ContentType = application/vnd.apple.mpegurl Set-Cookie = some value
Please suggest me what could be wrong
解决方案
尝试清除 HTTP 客户端标头。我遇到了同样的问题,然后清除了 HTTP 客户端标头并且它起作用了。
httpClient.DefaultRequestHeaders.Clear();
在发送请求之前应该解决问题。
推荐阅读
- spring - 如何从 Java 文件中获取值到 jsp?
- python - 在 tf.keras 中使用 CsvDataset for model.fit 来自 CSV 的特征和标签
- angular - 将 Angular 6 应用程序托管到 firebase
- html - 如何将 Godaddy 服务器中的图像链接到我的 html 电子邮件正文
- javascript - AngularJS 将事件发送到另一个控制器($broadcast、$window.localStorage 等)
- django - Django:将 url slugs 传递给表单集查询集
- node.js - Node js:在 Json 数组中搜索动态 json 对象
- django - 使用 Django Rest 检索图像
- javascript - node.js 多个回调/回调串行执行
- php - PHP会话数据不持久