网页导航已取消,在 asp.net 网络表单中收到消息
Navigation to the webpage was canceled getting message in asp.net web form
当我将 aspx 页面下载为图像格式时,下载的图像中出现以下错误消息,但本地主机每个人都认为只有在上传到实时服务器时才能正常工作,然后下载下载的文件,但内部文件消息不是我的 aspx数据显示。
Navigation to the webpage was canceled
下面是我下载的带有消息的图片文件
我正在尝试使用 win 表单 WebBrowser 控件截取网页的屏幕,下面是我的代码
下面是将 URL 分配给用于下载的文本框的代码
protected void Page_Load(object sender, EventArgs e)
{
txtweburl.Text = "http://example.com/dicdownload.aspx?VisitedId=DIC_V00025";
}
下面是使用线程生成屏幕的代码
protected void btnscreenshot_click(object sender, EventArgs e)
{
// btnscreenshot.Visible = false;
allpanels.Visible = true;
Thread thread = new Thread(GenerateThumbnail);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
private void GenerateThumbnail()
{
// btnscreenshot.Visible = false;
WebBrowser webrowse = new WebBrowser();
webrowse.ScrollBarsEnabled = false;
webrowse.AllowNavigation = true;
string url = txtweburl.Text.Trim();
webrowse.Navigate(url);
webrowse.Width = 1400;
webrowse.Height = 50000;
webrowse.DocumentCompleted += webbrowse_DocumentCompleted;
while (webrowse.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
}
}
在下面的代码中,我在下载删除相同文件后保存图像文件
private void webbrowse_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// btnscreenshot.Visible = false;
string folderPath = Server.MapPath("~/ImageFiles/");
WebBrowser webrowse = sender as WebBrowser;
//Bitmap bitmap = new Bitmap(webrowse.Width, webrowse.Height);
Bitmap bitmap = new Bitmap(webrowse.Width, webrowse.Height, PixelFormat.Format16bppRgb565);
webrowse.DrawToBitmap(bitmap, webrowse.Bounds);
string Systemimagedownloadpath = System.Configuration.ConfigurationManager.AppSettings["Systemimagedownloadpath"].ToString();
string fullOutputPath = Systemimagedownloadpath + Request.QueryString["VisitedId"].ToString() + ".png";
MemoryStream stream = new MemoryStream();
bitmap.Save(fullOutputPath, System.Drawing.Imaging.ImageFormat.Jpeg);
// You should put more appropriate MIME type as per your file time - perhaps based on extension
Response.ContentType = "application/octate-stream";
Response.AddHeader("content-disposition", "attachment;filename=" + Request.QueryString["VisitedId"].ToString() + ".png");
// Start pushing file to user, IIS will do the streaming.
Response.TransmitFile("~/ImageFiles/" + Request.QueryString["VisitedId"].ToString() + ".png");
Response.Flush();//Won't get error with Flush() so use this Instead of End()
var filePath = Server.MapPath("~/ImageFiles/" + Request.QueryString["VisitedId"].ToString() + ".png");
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
本地主机一切正常,但在实时下载带有该消息的图像时
我也检查了以下解决方案
IIS configuration: Navigation to the webpage was canceled when converting page to PDF using SautinSoft.PdfVision
首先,尝试重置 Internet Explorer 设置。
将站点添加到您信任的站点。
- 在 Internet Explorer 中,select 菜单中的工具 > Internet 选项
在顶部。
-
将出现 Internet 选项 window。 Select
安全选项卡。
然后点击
可信站点图标。
- 单击“站点”按钮。
-
受信任的站点 window 将打开。如图所示,在网站框中键入站点的 URL。点击
添加。然后添加一个“
s”之后
http(即使地址看起来像:”
https
://trusted.website.com”)。点击
重新添加。
是
确保您没有选中复选框
需要服务器验证 (https)。检查两次!
- 单击“关闭”按钮。
- 受信任的站点仍然 selected,单击“自定义级别”。
-
安全设置 – 可信站点区域 window 将打开。向下滚动,直到看到“
显示混合内容”。 Select
启用。
- 回到
Internet 选项 window,单击
确定保存更改。再次尝试该网站,看看它是否能更好地适应这些设置。
在我的情况下,我们必须进行三个设置,然后我的下载部分才能正常工作
1) SSL 证书
2) 我的网络团队将最低版本的 IIS 升级到 IIS10
3) 将 IIS 设置为 64 位版本
唯一为我解决的问题是在托管 RDL 报告的服务器上禁用防火墙。
对于仍在尝试解决这个问题的任何人。对我来说,在我的代码中设置 webBrowser.ScriptErrorsSuppressed = false;
后它起作用了。试试吧。
当我将 aspx 页面下载为图像格式时,下载的图像中出现以下错误消息,但本地主机每个人都认为只有在上传到实时服务器时才能正常工作,然后下载下载的文件,但内部文件消息不是我的 aspx数据显示。
Navigation to the webpage was canceled
下面是我下载的带有消息的图片文件
我正在尝试使用 win 表单 WebBrowser 控件截取网页的屏幕,下面是我的代码
下面是将 URL 分配给用于下载的文本框的代码
protected void Page_Load(object sender, EventArgs e)
{
txtweburl.Text = "http://example.com/dicdownload.aspx?VisitedId=DIC_V00025";
}
下面是使用线程生成屏幕的代码
protected void btnscreenshot_click(object sender, EventArgs e)
{
// btnscreenshot.Visible = false;
allpanels.Visible = true;
Thread thread = new Thread(GenerateThumbnail);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
private void GenerateThumbnail()
{
// btnscreenshot.Visible = false;
WebBrowser webrowse = new WebBrowser();
webrowse.ScrollBarsEnabled = false;
webrowse.AllowNavigation = true;
string url = txtweburl.Text.Trim();
webrowse.Navigate(url);
webrowse.Width = 1400;
webrowse.Height = 50000;
webrowse.DocumentCompleted += webbrowse_DocumentCompleted;
while (webrowse.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
}
}
在下面的代码中,我在下载删除相同文件后保存图像文件
private void webbrowse_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// btnscreenshot.Visible = false;
string folderPath = Server.MapPath("~/ImageFiles/");
WebBrowser webrowse = sender as WebBrowser;
//Bitmap bitmap = new Bitmap(webrowse.Width, webrowse.Height);
Bitmap bitmap = new Bitmap(webrowse.Width, webrowse.Height, PixelFormat.Format16bppRgb565);
webrowse.DrawToBitmap(bitmap, webrowse.Bounds);
string Systemimagedownloadpath = System.Configuration.ConfigurationManager.AppSettings["Systemimagedownloadpath"].ToString();
string fullOutputPath = Systemimagedownloadpath + Request.QueryString["VisitedId"].ToString() + ".png";
MemoryStream stream = new MemoryStream();
bitmap.Save(fullOutputPath, System.Drawing.Imaging.ImageFormat.Jpeg);
// You should put more appropriate MIME type as per your file time - perhaps based on extension
Response.ContentType = "application/octate-stream";
Response.AddHeader("content-disposition", "attachment;filename=" + Request.QueryString["VisitedId"].ToString() + ".png");
// Start pushing file to user, IIS will do the streaming.
Response.TransmitFile("~/ImageFiles/" + Request.QueryString["VisitedId"].ToString() + ".png");
Response.Flush();//Won't get error with Flush() so use this Instead of End()
var filePath = Server.MapPath("~/ImageFiles/" + Request.QueryString["VisitedId"].ToString() + ".png");
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
本地主机一切正常,但在实时下载带有该消息的图像时
我也检查了以下解决方案
IIS configuration: Navigation to the webpage was canceled when converting page to PDF using SautinSoft.PdfVision
首先,尝试重置 Internet Explorer 设置。
将站点添加到您信任的站点。
- 在 Internet Explorer 中,select 菜单中的工具 > Internet 选项 在顶部。
- 将出现 Internet 选项 window。 Select 安全选项卡。 然后点击 可信站点图标。
- 单击“站点”按钮。
- 受信任的站点 window 将打开。如图所示,在网站框中键入站点的 URL。点击 添加。然后添加一个“ s”之后 http(即使地址看起来像:”
https ://trusted.website.com”)。点击 重新添加。
是 确保您没有选中复选框 需要服务器验证 (https)。检查两次!
- 单击“关闭”按钮。
- 受信任的站点仍然 selected,单击“自定义级别”。
- 安全设置 – 可信站点区域 window 将打开。向下滚动,直到看到“ 显示混合内容”。 Select 启用。
- 回到 Internet 选项 window,单击 确定保存更改。再次尝试该网站,看看它是否能更好地适应这些设置。
在我的情况下,我们必须进行三个设置,然后我的下载部分才能正常工作
1) SSL 证书
2) 我的网络团队将最低版本的 IIS 升级到 IIS10
3) 将 IIS 设置为 64 位版本
唯一为我解决的问题是在托管 RDL 报告的服务器上禁用防火墙。
对于仍在尝试解决这个问题的任何人。对我来说,在我的代码中设置 webBrowser.ScriptErrorsSuppressed = false;
后它起作用了。试试吧。