Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6219439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:46:50+00:00 2026-05-24T07:46:50+00:00

I have built and MVC3 application with a controller (Picture) and an action method

  • 0

I have built and MVC3 application with a controller (Picture) and an action method (GetImage) that returns File contents (in my case a jpeg image)

public FileResult GetImage(int pictureID)
    {
        return File(Server.MapPath("~/Content/pic" + pictureID + ".jpg"), "image/jpeg");
    }

When I access images in my views like

<a id="single_image"><img src="/Picture/1" /></a>

..I get the image displayed properly.

But when I apply jQuery Fancybox plugin to this image and click on the image, it displays the pop-up with byte[] data inside (something you would get when the file mime type is missing).

What am I doing wrong?

PS: Sorry I am unable to post any images but can email it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:46:51+00:00Added an answer on May 24, 2026 at 7:46 am

    Just get your images directly using Html.Content in your View.

    Forms

    <a id="single_image">
        <img src="<%= Html.Content("~/Content/pic" + model.pictureID + ".jpg") %>" />
    </a>
    

    Razor

    <a id="single_image">
        <img src="@Html.Content("~/Content/pic" + model.pictureID + ".jpg")" />
    </a>
    

    EDIT

    If you’re dead set on using a picture controller, then I would recommend having your PictureController have the Index action return an ActionResult

    public ActionResult Image(int id)
    {
        var dir = Server.MapPath("/Pictures");
        var path = Path.Combine(dir, id + ".jpg");
        return base.File(path, "image/jpeg");
    }
    

    This will however slow down your requests over a direct .jpg file access.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MVC3 vb.net Application using built in session management. I have an mvc3 application that
I have built an application in C# that I would like to be optimized
I have built a MS Access 2007 application that can create reports files in
I have built an application that uses SQL Express 2005 and I want to
I have built an application that listen to call state changes, and I want
I have built an application in CakePHP that lists businesses. There are about 2000
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I have an application built in ASP.NET MVC 3 that uses SQL CE for
I have application built on asp.net MVC3. Application runs fine but I see one
I have created a sample MVC3 application for BookShop. I have a create action.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.