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 8188177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:49:03+00:00 2026-06-07T02:49:03+00:00

I’m new to MVC (coming from object oriented C# exe apps) and Stackoverflow. I’ve

  • 0

I’m new to MVC (coming from object oriented C# exe apps) and Stackoverflow. I’ve been struggling with trying to run code efficiently using MVC. I have Model data that returns from the database and along with that data is a field of bytes that are a jpeg image. At this stage I’ve made one call to the database…

Now what I’m stuck on is that once the populated model data is in the view to be rendered, I can’t simply loop over it and render the image in each data row. The only thing that I’ve found to make it work is to call and Action method that returns a FileContentResult, but this requires a new call back to the database for each image anew.

For solutions I’ve tried three different approaches that have netted the following problems:

  1. I can’t seem to pass the byte array back to the controller via an Action method to
    satisfy how MVC wants to receive the FileContentResult back in the
    view. The Action method only wants to accept simple types.
  2. I obviously don’t want to ask the controller to go back to the database for the byte
    data that I already have in the View, especially when this will
    involve several round trips for each entry in my Model data.
  3. Using Data Uri works, but it’s not supported by enough browsers yet.

Could someone tell me what the best way to handle issues like this? Do I need to work with problem 1, or 2, or is there a different approach that I’m missing?

Here is the code I tried to use originally in problem 1 to pass the byte array back to the controller so I can render the FileContentResult:

<img src=" @{Html.RenderAction("RenderMemberImage", "Home", new { @pic = x.ThumbnailData });}" />

[HttpGet]
    public FileContentResult RenderMemberImage(byte[] pic)
    {
        return new FileContentResult(pic, "mime/jpeg");
    }
  • 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-06-07T02:49:05+00:00Added an answer on June 7, 2026 at 2:49 am

    The problem is that you’re trying to send a byte array from the browser to the server. Try something like this:

    (I haven’t compiled this but it should be close)

    <img src=" @{Html.Action("RenderMemberImage", "Home", new { @picId = x.Id });}" />
    
    [HttpGet]
    public FileContentResult RenderMemberImage(Guid picId)
    {
        var pic = new Models.Picture(picId);//or however you get your data out of the DB
        return new FileContentResult(pic.ThumbnailData , "mime/jpeg");
    }
    

    Basically for each image on the page the browser will make a request to the server to get the image.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.