Answered by:
Download issue in live IIS sever using asp.net c#

Question
-
User-471420332 posted
Download issue in live IIS sever using asp.net c#, getting below message in download image file
Navigation to the webpage was canceled
below is my downloaded image file with message
I am tring to take screen short of the web page using win form WebBrowser control below is my code
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"; }
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-differ IIS configuration: Navigation to the webpage was canceled when converting page to PDF using SautinSoft.PdfVision
Wednesday, August 21, 2019 1:34 PM
Answers
-
User665608656 posted
Hi mazhar,
According to your error message, I found an example of the same issue as yours.
You can follow the answer as follow:
1) SSL Certificates
2) My Network Team Upgrade lowest version IIS to IIS10
3) Set the IIS to 64 bit version
You can refer to this link : https://stackoverflow.com/a/57685965
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, August 28, 2019 9:23 AM
All replies
-
User665608656 posted
Hi mazhar,
According to your description, have you tried the solution you provided in the link?
This link Navigation is canceled when you browse to Web pages that are in different Internet Explorer security zones you have given us is a common method to solve this issue.
You can also refer to these links :
'Navigation to web page canceled' while signing in
Best Regards,
YongQing.
Thursday, August 22, 2019 2:46 AM -
User-471420332 posted
bro can you tell me exact problem. Already i have checked your first URL and i have to check your second url.. exact solution giving urls is not answer na.Thursday, August 22, 2019 3:42 AM -
User665608656 posted
Hi mazhar,
According to your description, can you tell me what this code means? Is this related to the click event you downloaded the image?
protected void Page_Load(object sender, EventArgs e) { txtweburl.Text = "http://example.com/dicdownload.aspx?VisitedId=DIC_V00025"; }
I have tested your code in my IIS, and everything worked well.
Here is the result :
Best Regards,
YongQing.
Monday, August 26, 2019 6:58 AM -
User-471420332 posted
Base on VisitedId=DIC_V00025 data will fill dicdownload.aspx page, just i have mention static and i am passing by query string value, local host every think is working fine
protected void Page_Load(object sender, EventArgs e) { txtweburl.Text = "http://example.com/dicdownload.aspx?VisitedId=DIC_V00025"; }
Tuesday, August 27, 2019 8:48 AM -
User665608656 posted
Hi mazhar,
According to your error message, I found an example of the same issue as yours.
You can follow the answer as follow:
1) SSL Certificates
2) My Network Team Upgrade lowest version IIS to IIS10
3) Set the IIS to 64 bit version
You can refer to this link : https://stackoverflow.com/a/57685965
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, August 28, 2019 9:23 AM