How to Display image from database using Generic Handler in ASP.Net MVC4 application

In this post, I am explain How to Display image from database using Generic Handler in ASP.Net MVC4 application.

In my previous Article I have expainted How to upload image to database and show in a Page without image handler in MVC4. Here I would like to explain How to Display image from database using Generic Handler in ASP.Net MVC4 application.

The previous Article How to upload image to database and show in a Page without image handler in MVC4. , is good because it Removes separate HTTP Requests for loading image from database and is suitable when used for very few images. But there is some limitation as well

  • Its increase image size approximately 20-25%.
  • If you put the base64 image directly in a page, it won't be cached separately.

We will overcome those limitations in this article.

Last 10 uploaded image

  • 2d10800db075486b5b24aa14a3f0cb40.jpg

  • 17499569_583058335237214_2763233303246009397_n.jpg

  • ddddddddd.jpg

  • ddddddddd.jpg

  • 1238491940_rodriguez-profileofachief.jpg

  • 50404870_zamok_shotlandii1.jpg

  • Vehicules-Voiture-683180.png.jpg

  • Vehicules-Voiture-683180.png.jpg

  • moto_0310.jpg

  • 17757203_833308073476961_2438196508126893225_n.jpg

How to Display image from database using Generic Handler in ASP.Net MVC4 application
 <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <section id="login">
                        @Html.Partial("_LoginPartial")
                    </section>
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("Home", "Index", "Home")</li>
                            <li>@Html.ActionLink("About", "About", "Home")</li>
                            <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>
                </div>
            </div>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>


Posted By :