Thursday, March 16, 2017

Download file using jquery

Unfortunately it is not easy or straightforward to download a file using jquery. Either window.open or a hidden IFrame control has to be used to make this possible. And things get worse when we want to use POST instead of GET method in the request.

This jquery extension makes it very convenient to download files in such cases:

https://jqueryfiledownload.apphb.com/

Web api 2 file download result

To download a file from web api 2 controller method, the approach described in this article works well:

http://stackoverflow.com/questions/21533022/web-api-2-download-file-using-async-taskihttpactionresult

Thursday, March 2, 2017

Download excel (or other format) file from web api controller method

Since javascript does not recognize downloadable file formats, setting mere content-type header is not enough when we want to provide a facility to download a file from web api controller method.

This discussion provides a workaround for the issue:

http://stackoverflow.com/questions/14831860/download-excel-file-from-page-via-webapi-call

Export to excel in c#

The blog mentioned below lists several ways to export data to an excel file. All the different ways to export have been summarized quite neatly here.

http://techbrij.com/export-excel-xls-xlsx-asp-net-npoi-epplus


SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...