When I want to show an image I use something like this:
public ActionResult Show(int id) {
var MyFile = GetFromDB(id);
return File(MyFile.Data, MyFile.ContentType);
}
And in View:
<img alt ="" src='@Url.Action("show", new { id = 36 })'/>
So assume we have some other types of file like txt, pdf, …
And I think to use a general tag to show all kind of files instead of <img>. Does any one have any idea about it?
It is not easy, because some files need initialization or need additional declarations to specify how they should be presented, but you can try with iframe:
It will use browser built-in way of presenting documents.