I'm struggling with a feature in my asp.net MVC application, in a controller action I am passed the URL of a PDF file which I want to return to the user, but I'm having difficulty implementing it. I'm currently using a WebClient but I'm not sure this is the best approach. I cannot return a RedirectResult as our firewalls will not allow it, so I need to download it and return it as the result of the controller action.
Below is a simplified snippet. I cannot use an off the shelf reverse proxy like Managed Fusion as we need to perform additional steps in the Action.
Any help would be appreciated.
public ActionResult GetPDF()
{
var documentUrl = Request["documentUrl"];
var wc = new WebClient();
var d = wc.DownloadData(documentUrl);
MemoryStream ms = new MemoryStream(d);
return new FileStreamResult(ms, "application/pdf");
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire