我有Windows窗体应用程序,我正在加载一个网站。我使用有效凭据登录到Windows窗体中的站点。
然后,我设法获得了有效的会话id &这就是URL在有效凭据之后的样子
var url = "http://www.somewebsite123.com/portal/sessionId=123";我使用Microsoft.mshtml & AxInterop.ShDocVw来获取授权页面的内容。
WebClient client = new WebClient();
using (Stream data = client.OpenRead(new Uri(url)))
{
StreamReader reader = new StreamReader(data);
string htmlContent = reader.ReadToEnd();但是在下面的一行中,它抛出了错误
strHTML = ((IHTMLElement)htmlContent.document).innerHTML.ToString();错误
Internal error (WWC-00006)
An unexpected error occurred: ORA-01403: no data found (WWV-16016)我如何摆脱这个错误?
发布于 2018-02-01 18:30:23
当WebClient达到4XX或5XX时,可以在WebException.Response中找到实际的DOM内容:
try {
// Webclient that raise 4XX
}
catch (WebException webex)
{
using (var streamReader = new new StreamReader(webex.Response.GetResponseStream())) {
var domContent = streamReader.ReadToEnd();
}
}https://stackoverflow.com/questions/48560352
复制相似问题