Opening or downloading an excel file from aspx web page fails It doesn t open in application

0 votes

We have a solution that turns an Excel file from an ActiveReport-based report. In general, this works perfectly, however in some circumstances, for some incredibly bizarre reason, the downloading of the Excel file doesn't begin, and the Excel file instead opens in a web browser window without prompting the user to choose whether to open or save the created Excel file.

On a virtual machine powered by Windows Server 2019, our application is now executing. However, everything works well if I log in to the web server on that virtual machine from a different computer, launch the same program, and export the same report into an Excel file. I can easily access the Excel document in Excel or an Excel viewer when the web browser asks if I want to save or open it.

Another oddity is that not all servers hosting this application experience this issue. Additionally, it appears that similar issues arise if the server only has the Microsoft Office Excel viewer installed. This isn't always the case, though. It appears there are no issues if Excel's full version is installed.

We have tried everything that we have found. We have set the browser flags ( https://learn.microsoft.com/en-US/troubleshoot/browsers/how-to-set-ie-to-open-office-documents-in-office-program and https://www.thewindowsclub.com/make-internet-explorer-open-linked-office-documents-in-the-appropriate-office-program ) and went through dozens of web pages and reinstalled Excel Viewer.

Still, it seems that this problem is not related to browser flags at all, since this works fine in other servers even the browser flag values are not set in registry keys. So, to me, the problem seems to be in the web browser settings on the server. I just cannot imagine where. The web browser installed on the server is IE 11.

Any help is highly appreciated.

Oct 20 in Others by Kithuzzz
• 20,660 points
60 views

1 answer to this question.

0 votes
In regards to your first edit, the Content-Disposition header is crucial. This header is set to attachment in the current working copy. This informs the browser that the file is a download and has to be saved or opened with another application. Furthermore, it changes the filename to "ExcePreview.xls." The default value for Content-Disposition, if it is not set, is inline, which informs the browser that the content is or should be shown in a web page. As can be seen in your first screenshot, ExcelPreview.aspx is still the filename. There is no guarantee that this will happen, but certain systems may take into account the Content-Type header, disregard the aspx extension, sniff the content, and treat the response as a downloaded excel file.
answered Oct 20 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How can I open a URL in Android's web browser from my application?

ry this: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri ...READ MORE

answered Jun 14 in Others by polo
• 1,480 points
890 views
0 votes
1 answer

Unable to download excel file from src/assets in development/qa/prod environment for angular application

Try this: this.HttpClient.get("./assets/sample.xlsx",{responseType: "blob"}).subscribe((res:any) => ...READ MORE

answered Nov 12 in Others by narikkadan
• 37,660 points
51 views
0 votes
1 answer

How to open an Excel file in C#?

You must have Microsoft Visual Studio Tools ...READ MORE

answered Nov 13 in Others by narikkadan
• 37,660 points
31 views
0 votes
0 answers

How to open a new tab or a new window while writing an exam in AI - Onlime Remote Proctored

How to open a new tab or ...READ MORE

Jul 20, 2020 in Others by vimalkamal
• 120 points
2,474 views
0 votes
1 answer

Export DataTable to Excel File

Add Interop References. First we need to ...READ MORE

answered Jun 9 in JQuery by gaurav
• 22,040 points
93 views
0 votes
1 answer

How to create and download excel document using asp.net

First, download the Open XML Format SDK 2.0. It comes ...READ MORE

answered Oct 3 in Others by narikkadan
• 37,660 points
103 views
0 votes
1 answer

Authenticate on an ASP.Net Forms Authorization website from a console app

Essentially, we need to record a regular ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
320 views
0 votes
1 answer

Download file from URL in Excel 2019 (it works on Excel 2007)

The Sub Code looks fine. Check the ...READ MORE

answered Oct 7 in Others by narikkadan
• 37,660 points
87 views
0 votes
1 answer

Create Graph from data in an excel file

Your first step would be to become ...READ MORE

answered Oct 17 in Others by narikkadan
• 37,660 points
37 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP