简体   繁体   中英

HttpWebRequest.AllowAutoRedirect problem with Content-Disposition

If you set AllowAutoRedirect of HttpWebRequest to true , then it automatically redirects until it reaches some content. For example on sourceforge.net it redirect to mirror and then mirror would return the content in response. Problem is, the final response doesn't contain any Content-Disposition header, instead it's prior response has one, which redirect us to the last URL where download begins. If AllowAutoRedirect is set to true then we miss the file name and if set to false, we should redirect manually and keep an eye out for Content-Disposition . Any idea ?

Seems to me like a broken webapp. Anyhow, I would work around it by doing the redirects manually, instead of being handled by HWR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM