HttpWebRequest SSL 授权表

发布于 2024-08-17 07:15:42 字数 1521 浏览 4 评论 0原文

我以前从未尝试过,但现在我确实需要获得 Sprint 网站(www.sprint.com)的授权。

你们能帮我理解这实际上是如何运作的吗?

我正在尝试这样做,但显然我错过了一些东西。要么是关于 cookie 的事情 或 ssl 或其他东西,我不知道。

  HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(
                                                "https://sso.sprintpcs.com/sso/Login.do");
  CookieContainer cookieContainer = new CookieContainer();
  webRequest.CookieContainer = cookieContainer;
  webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0;
                          chromeframe; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; 
                          .NET CLR 3.0.30729; Tablet PC 2.0; .NET4.0C; .NET4.0E)";
  webRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, 
                       image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash,
                       application/vnd.ms-excel, application/msword, */*";

  webRequest.Method = "POST";
  webRequest.Host = "manage.sprintpcs.com";

  string strUserId = "kindauser";
  string strPass = "kindapass";

  ASCIIEncoding encoding = new ASCIIEncoding();
  string postData = "userid=" + strUserId + "&password=" 
                    + strPass + "&userExperince=USC allowlogin=false";

  byte[] data = encoding.GetBytes(postData);
  Stream requestStream = webRequest.GetRequestStream();
  requestStream.Write(data,0,data.Length);

  HttpWebResponse myHttpWebResponse = (HttpWebResponse)webRequest.GetResponse();

I've never tried before, but now I really need to get through authorization on Sprint's site (www.sprint.com).

Could you guys help me to understand how this actually works?

I'm trying to do like this, but obviously I'm missing something. Either something about cookies
or ssl or other stuff, I don't know.

  HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(
                                                "https://sso.sprintpcs.com/sso/Login.do");
  CookieContainer cookieContainer = new CookieContainer();
  webRequest.CookieContainer = cookieContainer;
  webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0;
                          chromeframe; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; 
                          .NET CLR 3.0.30729; Tablet PC 2.0; .NET4.0C; .NET4.0E)";
  webRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, 
                       image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash,
                       application/vnd.ms-excel, application/msword, */*";

  webRequest.Method = "POST";
  webRequest.Host = "manage.sprintpcs.com";

  string strUserId = "kindauser";
  string strPass = "kindapass";

  ASCIIEncoding encoding = new ASCIIEncoding();
  string postData = "userid=" + strUserId + "&password=" 
                    + strPass + "&userExperince=USC allowlogin=false";

  byte[] data = encoding.GetBytes(postData);
  Stream requestStream = webRequest.GetRequestStream();
  requestStream.Write(data,0,data.Length);

  HttpWebResponse myHttpWebResponse = (HttpWebResponse)webRequest.GetResponse();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2024-08-24 07:15:42

我会执行以下操作 - 这适用于您想要与网站交互的所有情况。

1) 获取 Firefox 以及 Firebug 扩展。
2)清除firefox内容和cookie缓存
3)使用firefox来做场景——登录网站,例如。
4) 此时,firebug 会向您显示与 cookie 标头等一起发送的请求的确切顺序。

5) 现在尝试使用代码复制此内容。

I would do the following - and this applies to all cases where you want to interact wit a website.

1) get firefox, along with firebug extension.
2) clear the firefox content and cookie cache
3) use firefox to do the scenario - logging into the website, for eg.
4) At this point, firebug shows you the exact sequence of requests sent along withh the cookie headers, etc.

5) Now try to replicate this using code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文