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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - ttyp

火苗-批量改名最新V1.0.5 喂来猫-超强工具集最新版 V1.0.9.0 ASP.NET图形化的曲线图类 JS写的一个功能齐备的treeview控件 输入自动完成类 定时检查网站是否掉线的批处理 code collection 0.44版 发布 JS代码的格式化和压缩 JS代码混淆初步 OUTLOOK菜单类 WEB打印分页类(JS) - ttyp - 博客园 自动配置IE代理脚本 XP下IIS不能添加扩展名映射的BUG js编写的语法高亮引擎 js写的Hashtable类 INF文件格式小结 自动提示效果 超强的WEB表格组件 关于设置WebControls里的treeview控件的图片路径
使用MemberShip时,用HttpWebRequest抓数据
ttyp · 2009-04-09 · via 博客园 - ttyp

最近在做一个项目,因为是分层设计,为了各层之间解耦,我们采用了HttpWebRequest来抓取同域下的文件数据(动态生成的)来生成新的对象.我们生成数据页的handler都是以.do结尾的,以示区分.但是这也带来了问题,在使用HttpWebRequest抓数据时,通不过验证.但是我们使用AJAX同样也是.do结尾的啊,却可以使用,奇怪!网上找Membership的验证原理,资料及其缺乏.多是设置cookie之类的,也试了好多次,均不奏效!事实也证明,当我们禁用cookie时,membership认证也同样起作用,设置cooke这条路走不通.陷入僵局!

只好在分析,为什么ajax请求行?而HttpWebRequest请求就不行呢?有什么特殊情况.打开我们经典的调试分析工具fiddler2.0,看看ajax传了什么

看到有.User一节的时候,我们眼睛一亮.或许给请求的头加上一个.User一节就能认证了,说做就做

Code

运行,调试,全部通过,大功告成!

同理,如果碰到membership认证的网站,想抓网页,可以先注册一个用户,然后用fiddler查看用户的.User这一节,加入你程序的头里,就能通过验证了

总结:为什么ajax能抓,而HttpWebRequest不能抓,原因可能是ajax是使用的js调用,而js是aspx页面的一部分,aspx页面的请求当然能使用membership.而HttpWebRequest直接请求的是.do页面,不受.net管理.

雕虫小技,权当抛砖引玉,欢迎访问测试我们的网站江西搜才网(http://www.jxscw.com)