取消导航到该网页,以asp.net Web形式获取消息 [英] Navigation to the webpage was canceled getting message in asp.net web form

查看:95
本文介绍了取消导航到该网页,以asp.net Web形式获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将aspx页面下载为图像格式,然后在下载的图像中出现以下错误消息时,但是本地主机每个人都认为只有当上传到实时服务器然后下载文件时,才能正常工作,但是内部文件消息不是我的aspx数据显示的

When i am download aspx page to image format then getting below error message in downloaded image, but local host every think working fine only when upload into live server then downloaded file is download but inside file message is coming not my aspx data showing.

Navigation to the webpage was canceled

下面是我下载的带有消息的图像文件

below is my downloaded image file with message

我想使用下面的win表单WebBrowser控件来使网页显示的简短,这是我的代码

I am tring to take screen short of the web page using win form WebBrowser control below is my code

下面是将URL分配给文本框以供下载的代码

Below is code assigning URL to textbox for downloading

  protected void Page_Load(object sender, EventArgs e)
{

   txtweburl.Text = "http://example.com/dicdownload.aspx?VisitedId=DIC_V00025";

 }

下面是使用线程生成screeen的代码

Below is code for generate screeen using thread

  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();
    }
}

在下面的代码中,我在下载图像后将其保存,并删除了相同的文件

In below code I am saving the image file after download deleting the same file

        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);
    }


}

本地托管一切正常,但是在实时下载带有该消息的图像时

Local host everything working fine but when it is in live downloading the image with that message

我也检查了以下解决方案

I have check with below solution also

https://support.microsoft.com/en-in/help/967941/navigation-is-canceled-when-you-browse-to-web-pages-that-are-in-不同

IIS配置:使用SautinSoft.PdfVision将页面转换为PDF时,取消了对网页的导航

推荐答案

就我而言,我们必须进行三个设置,然后我的下载部分才能正常运行

At my case we have to do three setting then my download part working perfectly fine

1)SSL证书

2)我的网络团队将最低版本的IIS升级到IIS10

2) My Network Team Upgrade lowest version IIS to IIS10

3)将IIS设置为64位版本

3) Set the IIS to 64 bit version

这篇关于取消导航到该网页,以asp.net Web形式获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆