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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:36:05+00:00 2026-05-26T02:36:05+00:00

If I call the GetImage action method directly ie: localserver/admin/GetImage?ProductID=36 it prompts me to

  • 0

If I call the GetImage action method directly ie: localserver/admin/GetImage?ProductID=36 it prompts me to download the file. Upon download, even when the file has the correct extension it does not open, testing with regular *.jpeg images from my pictures folder.
Also how do I set the filename when saving the file to database, do I need to create additional varchar type etc. field in database just for the filename ?

Once assigned to productMedia.ImageData the data is also all zeroes, hence null. Unlike the “image”, which has varying digits in there. Maybe it should be image.InputStream.Write and not image.InputStream.Read ? Tried it but still no go.

View

@using (Html.BeginForm("SaveProduct", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))

Here’s the saving procedure:

   if (image != null)
            {
                var ProductMedia = new ProductMedia();
                ProductMedia.ImageMimeType = image.ContentType;
                ProductMedia.ImageData = new byte[image.ContentLength];
                image.InputStream.Read(ProductMedia.ImageData, 0, image.ContentLength);
                ProductMedia.ProductID = product.ProductID;
                context.ProductMedias.AddObject(ProductMedia);
                context.SaveChanges();
            }

and the GetImage method:

public FileContentResult GetImage(int productID)
        {

            var ProductImages = context.ProductMedias.FirstOrDefault(x => x.ProductID == productID);

            if (ProductImages != null)
            {

                return File(ProductImages.ImageData, ProductImages.ImageMimeType);

            }
            else
            {
                return null;
            }


        }
  • 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-26T02:36:05+00:00Added an answer on May 26, 2026 at 2:36 am

    Nothing wrong with your GetImage method check your saving procedure for correct content type correct data. And in database check whether you have enough size for the image in ImageData column.
    For the second question , Yes you need a separate column for file name.

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

Sidebar

Related Questions

i want to call a method from a code-behind file. I already read all
Call to undefined method after upgrading to PHP 5.4.0 mentions a few APC bug-reports
Call me stupid but this thing has been eating away my productive time like
Call the parent method.How to implement? function Ch() { this.year = function (n) {
before call protected void onSubmit() { , what method is called by wicket? my
I'm making a call to an MVC controller method. The return type is FileStreamResult.
AJAX Call $.ajax({ url: '/api/Inventory', cache: false, type: 'POST', data: json, contentType: 'application/json, charset=utf-8',
I call from a spreadsheet module a function that does some processing in another
I call a function like this: call_facebook(103138046395999, samåkning.se, http://www.facebook.com/samakning, page); call_facebook(16089699074, Jag ska köra
Users call a web service API in my PHP code but don't properly encode

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.