Veera
Veera

Reputation: 3492

Download PDF with other name. ASP.NET

I was asked to solve an ASP.NET Question below by my friend.

The question is:

A folder named 'Files' is in the server with a pdf file named Emp_Details.pdf, Once the URl 'www.MyDomailName.com/ShowDetails.pdf' is browsed. The pdf in server (Emp_Details.pdf) must be downloaded.

It looks strange for me. How the pdf name 'ShowDetails.pdf' will redirect to the physical pdf file 'Emp_Details.pdf'.

Upvotes: 0

Views: 236

Answers (2)

Instead of storing your files in such a relative file path, you can very well store it in some local/network folder in the server. Upon user request to download, read the file and stream it to the browser using "application/octet-stream" as content type. Hope this helps

Upvotes: 0

TejSoft
TejSoft

Reputation: 3315

To solve this you have to write a custom HTTP Handler. The handler will trap the request for a ".pdf" file and based on logic inside it will return a response that will have the pdf from the "Files" folder.

You can read on how to write Http Handlers: here

Upvotes: 2

Related Questions