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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:16:03+00:00 2026-06-15T18:16:03+00:00

I have code which has generated an image of a Qr Code into the

  • 0

I have code which has generated an image of a Qr Code into the .NET Bitmap object. The code which generates this is called when a button is pressed on the page, like so:

    public ActionResult GenerateQrCode()
    {
        Bitmap qrCodeImage = Generate();
        return RedirectToAction("QrCodeGenerator");
    }

It’s a method in an MVC controller for the page.

When the button is pressed, an image is generated, and we are navigated back to the page.

So from here, what steps do I need to take to output this bitmap image to my web page (a .cshtml file). Bearing in mind that I am using ASP.NET MVC.

One thing I seen online is that people were saving the image to the ‘Response.OutputStream’. I’m not quite sure if that is relevant to ASP.NET MVC.

Thanks

  • 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-15T18:16:05+00:00Added an answer on June 15, 2026 at 6:16 pm

    The controller action need to return a FileStreamResult. This is how you do it

    public static byte[] ConvertToByteArray(this Image img)
    {
        using (var stream = new MemoryStream())
        {
            img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            return stream.ToArray();
        }
    }
    
    public ActionResult GenerateQrCode()
    {
       Bitmap qrCodeImage = Generate();
       //write your own methode to convert your bit map to byte array, here is a link
       //http://stackoverflow.com/questions/7350679/convert-a-bitmap-into-a-byte-array-in-c
       byte[] byteArray = qrCodeImage.ConvertToByteArray();
       return File(byteArray, "image/jpeg");
    } 
    

    And in your view, you can do something like this

    <img src="@Url.Action("GenerateQrCode")" alt="qr code" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master page in my asp.net MVC project, which has code like
We have a piece of code which saves a .Net System.Drawing.Bitmap to file. The
I have code which has a drop down list. And when a certain option
I have a C++ code which has 3 array declarations. float A[NUM]; float B[NUM];
I have some code which I think has extra release statements. Is the code
Imagine you have class A which has code which runs as method M. And
I have a C code in which I have a structure declaration which has
I have code which performs query on Jboss server. It has JNDI based datasource
I have a large library of code which has a few (much too few)
I have a lot of pieces of code which has to be run one

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.