0

I have a controller method set up for file download, and it works (user is prompted to open/save file) if the method is called directly using a hyperlink. However, if I chose to explicitly call the method by doing an explicit get request, I don't get the prompt for the file download, although the action method is successfully called.

    $("#id").click(function (e) {
        e.preventDefault();
        var postdata = { filename: $("#filename").text() };
        $.get("/Test/Fix", postdata);
    });

Does anyone know a workaround for this? Or is this by design?

lala
  • 73
  • 2
  • 8

1 Answers1

0

use window.location='your desired server action path with proper parameters';

so the final code will look like:

$("#id").click(function (e) {
        e.preventDefault();
        var filename = $("#filename").text();
        window.location= "/Test/Fix?filename="+filename;
    });

Hope this will help :)

Md Hasan Ibrahim
  • 1,808
  • 17
  • 27