vendredi 27 avril 2018

ASP.NET MVC open file in new window

I create a MVC Web application. I need to open the pdf file when user clicks the 'View' button on the page. The filepath where the pdf is stored is read from the database and it is a file on c: How do I open it in my code? I have this code:

@Html.ActionLink("Read", "ViewOnline", new { controller = "Home", id = item.Id }, new { target = "_blank" }, new { @class = "btn btn-default" })

And my Controller

public ActionResult ViewOnline(int id)
        {
            string link = BookBUS.Instance.GetBooks().Find(x => x.BookID == id).FilePath;
                if (link != null)
                {
                    TempData["Embed"] = VirtualPathUtility.ToAbsolute(link);
                }
            }




Aucun commentaire:

Enregistrer un commentaire