HttpRequest的:通过AuthLogin [英] HttpRequest: pass through AuthLogin
问题描述
我需要做一个简单的程序,在给定的凭据某些网站记录,然后导航至某个元素(链接)。
甚至有可能(我的意思是Authlogin东西)
I would need to make a simple program that logs with given credentials to certain website and then navigate to some element (link). It is even possible (I mean this Authlogin thing)?
编辑:对不起 - 我是公司的机器上,我无法点击投票或添加评论 - 页面上显示已完成,但网页上有错误(IE ..)。 !我很欣赏你的答案和意见,你帮了我很多。
SORRY - I am on my company machine and I cannot click on "Vote" or "Add comment" - the page says "Done, but with errors on page" (IE..). I do appreciate your answers and comments, you have helped me a lot!
推荐答案
主要要做的事情是:
- 开始使用提琴手,看看有什么需要是派和以什么方式
-
假设我们正在谈论你可能需要使用正常的Web形式的
的CookieContainer
与你的的WebRequest
,以接受来自登录请求的cookie,然后发送后续的请求(如上下文不会自动地由<$ C维护时再提供文件S $ C>的HttpWebRequest ): -
- Start using Fiddler to see what needs to be sent and in what way
Assuming we're talking a normal web form you'll probably need to use a
CookieContainer
with yourWebRequest
s in order to accept the cookies that come from the login request and then re-supply them when sending subsequent requests (such context is not automagically maintained byHttpWebRequest
) :-
CookieContainer _cookieContainer = new CookieContainer();
((HttpWebRequest)request).CookieContainer = _cookieContainer;
这篇关于HttpRequest的:通过AuthLogin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!