使用C#实现模拟登录 [英] Implement impersonation login using C#

查看:217
本文介绍了使用C#实现模拟登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i want to request a website in my application.
Authentication required for this website when i request it via IE.
i have the id and pw. how can i request it via code?







Authentication 







the login area is not a form build using html. it is a windows popup Authentication window.





我尝试过:





What I have tried:

string authenticationUrl = @"https://xxx"; // it'use https, not sure if this impact anything.
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(authenticationUrl);
            req.Credentials = new NetworkCredential("id", "pw");
            using (WebResponse wr = req.GetResponse())
            {
                //error here: Authentication failed because the remote party has closed the transport stream.
            }

推荐答案

您可以使用凭据创建HTTP Web请求对象(Google是您的朋友)。您对响应的处理取决于您。
You can create a HTTP web request object with credentials (google is your friend). What you do with the response is up to you.


这篇关于使用C#实现模拟登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆