Alan
Alan

Reputation: 461

Hide filedownload source from client

I actually have to wirte a service which downloads some PDF Reports from an external resource and pass it to the client like a proxy. The clue is that I have to entirely hide the link to the resource from the client calling the service and behave as if the client would download that report directly from my server. On Stackoverflow (source here) i found something like this

public ActionResult GetPdf(string filename)
{
    using (var client = new WebClient())
    {
        var buffer = client.DownloadData("http://foo.com/bar.pdf");
        return File(buffer, "application/pdf", "report1.pdf");
    }
}

At a glance it seems like a pretty nice option. But I'm not sure if thats the way to achieve what I have to. Is this piece of code really hiding the entire traffic from the client or am I on the wrong track using this solution (what are the best practices here)?

Thanks in advance.

Upvotes: 0

Views: 64

Answers (1)

Nikolay
Nikolay

Reputation: 12245

Yes, this code hides the "initial" source completely.

Upvotes: 1

Related Questions