这个问题是我的后续问题上一个问题 https://stackoverflow.com/questions/56279/export-aspx-to-html关于从 ASPX 页面获取 HTML。我决定尝试使用 webclient 对象,但问题是我获取了登录页面的 HTML,因为需要登录。我尝试使用 webclient 对象“登录”:
WebClient ww = new WebClient();
ww.DownloadString("Login.aspx?UserName=&Password=");
string html = ww.DownloadString("Internal.aspx");
但我仍然每次都能看到登录页面。我知道用户名信息没有存储在 cookie 中。我一定是做错了什么或者遗漏了重要的部分。有谁知道它可能是什么?
尝试设置 WebClient 对象的凭据属性
WebClient ww = new WebClient();
ww.Credentials = CredentialCache.DefaultCredentials;
ww.DownloadString("Login.aspx?UserName=&Password=");
string html = ww.DownloadString("Internal.aspx");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)