I want to load a file from a URL into memory in a controller and pass it back to the user in the view
This is what I have
public class TickController : ApiController{
[Route("api/Download")]
[HttpPost]
public async Task<StreamContent> Download([FromBody]string url){
WebRequest request = FtpWebRequest.Create(url);
using (WebResponse response = request.GetResponse())
{
//load file into stream
Stream responseStream = response.GetResponseStream();
}
//return file to view
}
This is what the above function is called by;
async downloadAttach(URL: any) {
window.open(await WebApiManager.post('Download', URL));
}
}
However I havent been able to work out how to force it to download on the users side when they click a HTML button
I have seen solutions that work with ControllerBase and Web.MVC. But as shown above I am using ApiController class so I cannot use those methods.
Any help would be appreciated.