How to show any document file content in web browser + mvc
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Dec 11, 2014, 3:32 AM EST
Create an ActionMethod which will return FileResult like
public ActionResult GetTextFile()
{
FileInfo f = new FileInfo("path");
return File(f, "application/pdf");
}
This will return pdf file stored on server. Similarly you can download any type of files. Yu can use FileStream as well.
Hope this answeres your question. Mark it as answered if it helped you.