Skip to main content
added 19 characters in body
Source Link
Baskovli
  • 630
  • 6
  • 15

In order to download file you have to use Microsoft.JSInterop JSInterop. There are many ways to implement your request. One way that i use is get the file as byte array then convert to base64string. Finally call the Methodfunction that you created in javascript from server.

In server side

js.InvokeVoidAsync("jsOpenIntoNewTab",
                            filename,
                            Convert.ToBase64String(ReportPDF())
                            );

In client side in js file

function jsOpenIntoNewTab(filename, byteBase64) {
var blob = b64toBlob(byteBase64);

var blobURL = URL.createObjectURL(blob);
window.open(blobURL);}

In order to download file you have to use Microsoft.JSInterop. There are many ways to implement your request. One way that i use is get the file as byte array then convert to base64string. Finally call the Method in javascript from server.

In server side

js.InvokeVoidAsync("jsOpenIntoNewTab",
                            filename,
                            Convert.ToBase64String(ReportPDF())
                            );

In client side in js file

function jsOpenIntoNewTab(filename, byteBase64) {
var blob = b64toBlob(byteBase64);

var blobURL = URL.createObjectURL(blob);
window.open(blobURL);}

In order to download file you have to use Microsoft JSInterop. There are many ways to implement your request. One way that i use is get the file as byte array then convert to base64string. Finally call the function that you created in javascript from server.

In server side

js.InvokeVoidAsync("jsOpenIntoNewTab",
                            filename,
                            Convert.ToBase64String(ReportPDF())
                            );

In client side in js file

function jsOpenIntoNewTab(filename, byteBase64) {
var blob = b64toBlob(byteBase64);

var blobURL = URL.createObjectURL(blob);
window.open(blobURL);}
Source Link
Baskovli
  • 630
  • 6
  • 15

In order to download file you have to use Microsoft.JSInterop. There are many ways to implement your request. One way that i use is get the file as byte array then convert to base64string. Finally call the Method in javascript from server.

In server side

js.InvokeVoidAsync("jsOpenIntoNewTab",
                            filename,
                            Convert.ToBase64String(ReportPDF())
                            );

In client side in js file

function jsOpenIntoNewTab(filename, byteBase64) {
var blob = b64toBlob(byteBase64);

var blobURL = URL.createObjectURL(blob);
window.open(blobURL);}