惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - 爱车龟速兔

如何通过Spring读取Properties文件 Kylin使用笔记-1: 安装 Kylin使用笔记-0: kylin介绍 jquery validate不用submit提交,用js提交的 NPOI 读取单元格的格式 一些列开源的验证组件 .NET的轻量级模板引擎 JNTemplate Aspose.OCR for .NET 高速集群监控系统 SuperMon Redis on Windows jQuery 工具提示插件 DTooltip 轻量级jQuery网格插件——ParamQuery 矢量 开源JS仪表盘 JustGage C#的HTTP开发包 HttpLib Query 图像放大镜插件 Mlens sparky 一个趋势图的JavaScript插件 Windows SDK PGM相关文章翻译之三PGM Sender Options Windows SDK PGM相关文章翻译之一Reliable Multicast Programming
c#获得HTTP header中location的方法
爱车龟速兔 · 2013-03-20 · via 博客园 - 爱车龟速兔

2013-03-20 23:37  爱车龟速兔  阅读(1474)  评论(0)    收藏  举报

用HttpWebRequest获取网页信息时,页面可能会使用header跳转到新地址。

但是有时候不希望调整,想获得跳转后的地址,然后做些判断来决定是否跳转。

HttpWebRequest对象有个AllowAutoRedirect属性,指是否自动跳转到新地址,默认为true,改成false即可。

返回对象HttpWebResponse的header中location即为新地址。

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

req.AllowAutoRedirect = false;
HttpWebResponse response = (HttpWebResponse)req.GetResponse();

label_reponse.Text = response.Headers["location"];