Donate

ASP.NET MVC generates error = "OutputStream is not available when a custom TextWriter is used"

In a simple application I'm creating, I have a custom ActionResult class that returns an image data. In my view, I simply used:
<%= Html.Action("GetImage", "ImageCustom", new{id = item.CategoryID}) %>  
to call the custom action class ExecuteResult method. This method reads the image byte array and store's it in a stream object. However, the call generates an error stated in the title. Html.Action writes html which implements text writer class. The solution would be using Url.Action() embedded in the image src attribute:
<img src='<%= Url.Action("GetImage","ImageCustom", new {id = item.CategoryID}) %>'   
  alt="No Photo" width="100" height="100" />  
Greg

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.