MVC 5 & ASP.NET Best Practices – Some nice articles and tutorials.,-MVP-and-MVVM-Design-Patterns.html,-Dependency-Injection-and-Service-Locator.html Hope you like it…Happy Coding… 🙂  Advertisements

ASP.NET WebAPI – Return image from Api to View

if you want to return an Image (i.e. Byte[]) from Api Controller to Browser (view), use following method.  public HttpResponseMessage Get(string imageName, int width, int height) { Image img = GetImage(imageName, width, height); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue(“image/png”); return result;… Read More ASP.NET WebAPI – Return image from Api to View