MVC 5 & ASP.NET Best Practices – Some nice articles and tutorials.


  1. http://www.dotnet-tricks.com/Tutorial/mvc/N50P050314-Understanding-HTML-Helpers-in-ASP.NET-MVC.html
  2. http://www.dotnet-tricks.com/Tutorial/mvc/19D9140313-Exception-or-Error-Handling-and-Logging-in-MVC4.html
  3. http://www.dotnet-tricks.com/Tutorial/mvc/4XDc110313-return-View()-vs-return-RedirectToAction()-vs-return-Redirect()-vs-return-RedirectToRoute().html
  4. http://www.dotnet-tricks.com/Tutorial/mvc/E2S9150113-Enhancing-WebGrid-with-Insert-Update-and-Delete-Operations.html
  5. http://www.dotnet-tricks.com/Tutorial/mvc/18NI110113-Enhancing-WebGrid-with-ajax-in-MVC4.html
  6. http://www.dotnet-tricks.com/Tutorial/mvc/ODJa210113-Donut-Caching-and-Donut-Hole-Caching-with-Asp.Net-MVC-4.html
  7. http://www.dotnet-tricks.com/Tutorial/designpatterns/2FMM060314-Understanding-MVC,-MVP-and-MVVM-Design-Patterns.html
  8. http://www.dotnet-tricks.com/Tutorial/dependencyinjection/bSVa100413-Understanding-Inversion-of-Control,-Dependency-Injection-and-Service-Locator.html
  9. http://www.asp.net/signalr

Hope you like it…Happy Coding… 🙂 

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;
    }