I am trying to show the document located inside wwwroot folder in my .NET MVC Core application folder in an iframe.
Scenario:
I have a list of document on my Razor page: MyRazor.cshtml and there is a button for each list. When I click that button it takes me to the details of individual document using its Id.
When the page loads, the document gets downloaded instead of showing in iframe src.
Controller:
public ActionResult GetArticles(int id)
{
try
{
Articles getArticles = _articleRepository.GetArticles(id);
return View(getArticles);
}
catch (Exception)
{
return NotFound();
}
}
View:
<div class="card">
<iframe id="documentViewer" src="~/docs/@Html.DisplayFor(model => model.WordDocumentFile)" width="100%" height="700px;" frameborder="0"></iframe>
</div>
which is undesirable. I just want the show that document inside my iframe.
What am I missing?