I send a request via ajax and if response data success is true, I make a GET request in ajax success function:
success: function (data, status) {
if (!data["Success"]) {
alert("Error occurred: Cant read data properly," + data["Message"]);
return null;
}
window.location = '/Home/downloadanddelete?file=output.' + data["filetype"];
The problem is when Get request posted to controller the response is:
As you see the file request url is:"http://localhost:53091/Home/downloadanddelete?file=output.xml"
And I expect download this "output.xml" file and return the referrer page url.
here is download method in controller:
[HttpGet]
public ActionResult downloadanddelete(string file)
{
string fullName = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data", file);
if (System.IO.File.Exists(fullName))
{
return File(fullName, "application/xml");
}
return View("Index");
}
What is it wrong here?