- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在检索 HTTPWebRequest 时,有没有一种方法可以防止出现错误消息或以编程方式对弹出的消息单击"is"?下面显示的代码会导致一条警告消息,其文本为“此页面存在未指定的潜在安全风险。您要继续吗?”消息的标题是“Internet Explorer”。关于可能导致错误消息的原因的一些线索是:
• 它似乎不是由代码行 ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true) 中的 sslPolicyErrors 引起的;应该防止这种情况。
• 设置了 Internet Explorer 选项,以便网站 http://jobsearch.monster.com在受信任的站点列表中。
• 该消息在执行最后一行代码后出现:-oDoc.close();
• 可以通过运行代码以响应单击窗口窗体上的按钮来观察消息。
• 错误消息必须手动单击三次(是或否)才能使消息消失。
• 这是迄今为止唯一导致此错误消息的网站。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using System.Threading;
using System.Net;
using mshtml;
namespace FitCShp
{
public partial class frmThreadIssue : Form
{
public frmThreadIssue()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
HTMLDocumentClass oDoc;
oDoc = GetDoc();
}
public HTMLDocumentClass GetDoc()
{
string WebAddrs = "http://jobsearch.monster.com/PowerSearch.aspx?q=proven%20record%20relationship&where=portland%2C%20or&rad=20&rad_units=miles&tm=60";
IHTMLDocument2 oDoc = null;
HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(WebAddrs); //build the request
ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
Req.AllowAutoRedirect = true;
Req.ContentType = "application/x-www-form-urlencoded";
Req.KeepAlive = false;
Req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'";
HttpWebResponse resp = (HttpWebResponse)Req.GetResponse();
//Get the encoding of the response
System.Text.Encoding Enc = System.Text.Encoding.GetEncoding(resp.CharacterSet);
StreamReader sr = new StreamReader(resp.GetResponseStream(), Enc); //Create the stream reader
string sDoc = sr.ReadToEnd(); //read the stream that represents the Webdoc
sr.Close(); //close the stream
HTMLDocument ProfileHTML = new HTMLDocument();
oDoc = (IHTMLDocument2)ProfileHTML;
oDoc.write(sDoc);
oDoc.close(); //--- Error occurs here
return (HTMLDocumentClass)oDoc;
}
}
}
最佳答案
如果您的页面在 HTTPS 上下文中运行,但通过 HTTP 引用其他站点的元素,您将收到此安全警告。确保在 URL 中使用 HTTPS 引用所有引用的内容(例如图像、样式表等)。
关于c# - 如何在 HTTPWebRequest 期间阻止 Internet Explorer 安全警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5303291/
我正在使用 HttpWebRequest 登录页面并获取一些信息。然后,我使用该信息创建一个新的 HttpWebRequest 以获取更多信息。我不想使用 WebClient。 如何将使用第一个 Ht
我有一个包含指向某些文件的链接的页面。 我基本上需要访问页面的源代码来解析它并获取文件的所有超链接。 我的代码是这样的(我在网上很多地方都找到了一些代码..): "private static
我正在编写一个渐进式下载器作为可移植类库 (Profile=24)。它将支持以字节 block 的形式部分下载目标文件。 HttpClient 不可用,我将使用 HttpWebRequest,它具有用
我正在努力在 HttpWebRequest 之上构建一个流畅的 REST 客户端界面。/HttpWebResponse .NET 中的类型。到目前为止,一切都很好......但是我正在尝试开发一个可插
我有一个用 VB.NET 编写的应用程序( 不是 asp.net,它是一个 Windows 控制台应用程序)。我正在尝试调用一个 url(一个 html 页面)并将响应返回到一个字符串中。响应是直接的
我尝试使用 C# HTTPWebRequest 类登录 amazon.com,我可以登录但无法读取 header 中的多个 set-cookie 当服务器响应多个“Set-Cookie:”-heade
我正在测试 Web 核心 API,但收到 500 内部服务器错误。 我的 Controller 上的方法是; [Route("api/property")] public class Property
假设我正在检索一个 url,如下所示: string url = "http://www.somesite.com/somepage.html" HttpWebRequest req = (HttpW
当我使用 HttpWebRequest.Headers.Add("Cookie",value) 与 HttpWebRequest.CookieContainer 和结果从 HttpWebRequest
我已阅读以下 2 篇文章并尝试实现相同的文章。 我的代码是这样的,超时发生在这里 HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
我正在寻找一种使用 httpWebRequest 从 url 下载 excel 文件并以某种方式解析它的方法 - 这是否意味着将其转换为 .csv 文件,以便我可以简单地使用 TextFieldPar
当我尝试序列化 HttpWebRequest 时出现以下错误 Type 'System.Net.KnownHttpVerb' in Assembly 'System, Version=2.0.0.0,
我目前正在下载一个 HTML 页面,使用以下代码: Try Dim req As System.Net.HttpWebRequest = DirectCast(WebRequest.Creat
我读了这个 MSDN 喜欢它并运行它的例子。 http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.a
我有一个 ASP.NET MVC 操作,它通过 HttpWebRequest 将 GET 请求发送到另一台服务器。我想在新请求中包含原始操作请求中的所有 cookie。原始请求中的一些 System.
我正在尝试抓取具有用户身份验证的网站。我能够执行POST来发送登录信息并存储Cookie。但是,登录后,尝试访问 protected 页面时出现403错误。 $url = "https://some_
我正在使用 HttpWebRequest ,并且正在处理响应流。 HttpWebRequest是否有正确的处理方法? ,因为它不包含 close 或 dispose 方法? 最佳答案 如果该类有特殊的
我在REST服务中抛出一个错误,例如: throw new WebFaultException("bla bla bla", HttpStatusCode.HttpVersionNotSuppo
问题:此控制台应用调用 Azure 上托管的长时间运行的网页两次。我希望它只调用一次。 控制台应用程序因捕获的异常而失败:基础连接已关闭:接收时发生意外错误。 so question 如果我从 Chr
我试图弄清楚我的网络请求在最终到达最终内容之前被重定向了多少次。 我正在创建我的网络请求,如下所示: var httpRequest = (HttpWebRequest) WebRequest.Cre
我是一名优秀的程序员,十分优秀!