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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:13:31+00:00 2026-05-23T01:13:31+00:00

I have a simple form that uploads an image to a database. Using a

  • 0

I have a simple form that uploads an image to a database. Using a controller action, the image can then be served back (I’ve hard coded to use jpegs for this code):

public class ImagesController : Controller
{
    [HttpPost]
    public ActionResult Create(HttpPostedFileBase image)
    {
        var message = new MessageItem();
        message.ImageData = new byte[image.ContentLength];
        image.InputStream.Read(message.ImageData, 0, image.ContentLength);
        this.session.Save(message);
        return this.RedirectToAction("index");
    }

    [HttpGet]
    public FileResult View(int id)
    {
        var message = this.session.Get<MessageItem>(id);
        return this.File(message.ImageData, "image/jpeg");
    }
}

This works great and directly browsing to the image (e.g. /images/view/1) displays the image correctly. However, I noticed that when FireBug is turned on, I’m greeted with a lovely error:

Image corrupt or truncated: data:image/jpeg;base64,/f39… (followed by the base64 representation of the image).

Additionally in Chrome developer tools:

Resource interpreted as Document but transferred with MIME type image/jpeg.

I checked the headers that are being returned. The following is an example of the headers sent back to the browser. Nothing looks out of the ordinary (perhaps the Cache-Control?):

Cache-Control       private, s-maxage=0
Content-Type        image/jpeg
Server              Microsoft-IIS/7.5
X-AspNetMvc-Version 3.0
X-AspNet-Version    4.0.30319
X-SourceFiles       =?UTF-8?B?(Trimmed...)
X-Powered-By        ASP.NET
Date                Wed, 25 May 2011 23:48:22 GMT
Content-Length      21362

Additionally, I thought I’d mention that I’m running this on IIS Express (even tested on Cassini with the same results).

The odd part is that the image displays correctly but the consoles are telling me otherwise. Ideally I’d like to not ignore these errors. Finally, to further add to the confusion, when referenced as an image (e.g. <img src="/images/view/1" />), no error occurs.

EDIT: It is possible to fully reproduce this without any of the above actions:

public class ImageController : Controller
{
    public FileResult Test()
    {
        // I know this is directly reading from a file, but the whole purpose is
        // to return a *buffer* of a file and not the *path* to the file.
        // This will throw the error in FireBug.
        var buffer = System.IO.File.ReadAllBytes("PATH_TO_JPEG");
        return this.File(buffer, "image/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-05-23T01:13:31+00:00Added an answer on May 23, 2026 at 1:13 am

    Thanks everyone for all the help. I know this is is going to be a very anti-climatic ending for this problem, but I was able to “resolve” the issue. I tried building my code from another machine using the same browser/firebug versions. Oddly enough, no errors appeared. When I went back to the other machine (cleared all cache and even re-installed browser/firebug) it was still getting the error. What’s even more weird is that both Chrome/Firefox are now showing the error when I visit other websites.

    Again, thanks everyone for all their suggestions!

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

Sidebar

Related Questions

I have a simple .NET 2.0 windows form app that runs off of a
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have a site that has a simple HTML button in a form. All
I'm writing a simple app that's going to have a tiny form sitting in
I have a simple form with some plain html input like bellow using ASP.NET
I have a form that, among other things, accepts an image for upload and
I see a lot of people with Django apps that have image uploads are
I have a Form that I am using to receive an uploaded .csv file,
I have an image upload form that takes a title and a file for
I have a simple signup form that needs to track number of hits from

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.