Web 请求禁止自动重定向
在 .Net 2.0 中,使用 WebRequest 时如何禁止 AutoRedirect? 我发现一些源代码使用了AllowAutoRedirect 属性,但在我的WebRequest 上没有这样的属性。
In .Net 2.0 how can I disallow AutoRedirect when using WebRequest? I found some source code were there where used an AllowAutoRedirect property, but on my WebRequest there is no such property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将其转换为
HttpWebRequest
You need to cast it to a
HttpWebRequest
WebRequest
本身没有这样的属性,但HttpWebRequest
有。 如果转换为HttpWebRequest
,则可以将AllowAutoRedirect
设置为 false。如果您的网络请求确实不是
HttpWebRequest
,请解释它是什么类型的请求。WebRequest
itself doesn't have such a property, butHttpWebRequest
does. If you cast toHttpWebRequest
, you can setAllowAutoRedirect
to false.If your web request really isn't an
HttpWebRequest
, please explain what kind of request it is.