I want to upload a pdf file to the page. To load created in the controller the following method
public FileContentResult Read(int bookId) { Book book = context.Books.FirstOrDefault(b => b.Id == bookId); string path = Server.MapPath($"~/Content/Books/{book.GeneratedName}");//Путь к файлу string type = $"application/{GetType(book.GeneratedName)}";//Тип файла byte[] fileContents = System.IO.File.ReadAllBytes(path);//Получение файла в байтовом виде return new FileContentResult(fileContents, type); } View code that calls this method and generates content.
<p>@{Html.RenderAction("Read",new { bookId = Model.Id });}</p> But, when accessing this page, an exception is generated.
System.Web.HttpException: При использовании особого объекта TextWriter свойство OutputStream недоступно.