Reputation: 591
I want to display file on my form using MVC.
I am bringing a Byte[] array data from the Database, and using FileContentResult I am converting it into a file.I want to now display this file on my page for viewing . How can it be acheived. What code to write in my View for the same.
Upvotes: 0
Views: 925
Reputation: 171
You probably don't want to use FileContentResult, that is something generally used for providing the raw file.
In theory though there is nothing different in using any other url
<img src="@Html.ActionLink("View","Image",{id = Model.key})" />
Or you can provide that link in a pdf reference, or as a stylesheet etc.
Upvotes: 0
Reputation: 9899
Assuming you're using Razor, rendering a text file can be done as simple as:
<div>
@(new System.IO.StreamReader("myFile.txt")).ReadToEnd()
</div>
For PDF files, you'll have to find a third-party component to convert to HTML.
Upvotes: 0