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:
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:
Greg
<%= Html.Action("GetImage", "ImageCustom", new{id = item.CategoryID}) %>
<img src='<%= Url.Action("GetImage","ImageCustom", new {id = item.CategoryID}) %>' alt="No Photo" width="100" height="100" />
Comments
Post a Comment