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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:30:44+00:00 2026-06-12T09:30:44+00:00

I am currently using a function inside an ASP.Net ASMX web service to generate

  • 0

I am currently using a function inside an ASP.Net ASMX web service to generate a System.Drawing.Image. I would like to have this image (after converting to a png or something) passed to the browser as the reply to an AJAX call. (using jQuery’s $.ajax). I’ve been Googling but can’t seem to find out how, although I’m pretty sure it’s possible. Do I convert it to a Data URI somehow first, or what?

  • 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-12T09:30:44+00:00Added an answer on June 12, 2026 at 9:30 am

    I don’t think you can do that. In order to return the image, you should have a method which returns bytearray which I don’t think is of any use in javascript.
    My workaround is to save the image in a certain location and return the address of the image to clientside.

    Update: based on the comments, you can encode the image’s data to Base64 string and handle the DATA URI on your ajax callback.
    You can use JSON to represent the base64Encoded data, and on the ajax calklback, you can write something like:

    $("#myImage").attr("src", "data:image/png;base64,RETURNED_DATA_FROM_ASMX");    
    

    Here’s a sample code to convert your image to base64 in c#:

    public string ImageToBase64(Image image, 
      System.Drawing.Imaging.ImageFormat format)
    {
      using (MemoryStream ms = new MemoryStream())
      {
        // Convert Image to byte[]
        image.Save(ms, format);
        byte[] imageBytes = ms.ToArray();
    
        // Convert byte[] to Base64 String
        string base64String = Convert.ToBase64String(imageBytes);
        return base64String;
      }
    }
    

    To find out how to format a DATA URI, you can visit http://en.wikipedia.org/wiki/Data_URI_scheme#Format.

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

Sidebar

Related Questions

I am using ASP.NET MVC2 and I would like to make up a url
I'm currently creating an application using ASP.NET MVC. I got some user input inside
using ASP.NET MVC 2 I have a navigation menu inside my Master Page. In
I am currently using asp.net membership database on multiple apps. I am not looking
I'm using a asp.net slider inside an UpdatePanel within a page control . I
I'm rather new to web development so I'm using MVC with ASP.NET and I've
I'm using VS2010, asp.net c#. I have a WebMethod declared like this [WebMethod(EnableSession =
I have a custom MembershipProvider that I'm using in an ASP.NET 2.0 application. Inside
I am currently using this function inside my program. void CBar::DocumentComplete(IDispatch *pDisp, VARIANT *URL)
I am using ASP.NET Web Forms/C# . I researched about implementing BLL and DLL

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.