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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:14:57+00:00 2026-06-01T02:14:57+00:00

I want to save Image in Database with JSON web service .without image data

  • 0

I want to save Image in Database with JSON web service .without image data save.
But when send image byte It is not save. How to send or Recive Image with JSon webservie in window phone-7

My Webservice:

    [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
            public string Register(string emailID, string pwd, string name, string img)
            {
                ProfileDL _client = new ProfileDL();

                _client.Email = emailID;
                _client.Password = pwd;
            img = img.Replace(' ', '+');
            _client.Firstname = name;
            _client.Img = Convert.FromBase64String(img);
            _client.saveData();
            return "Y";
        }

WP7 Code:-



    //Convert Image to byte code
     private void photoChooserTask_Completed(object sender, PhotoResult e)
        { 
     imageBytes = new byte[e.ChosenPhoto.Length];
     e.ChosenPhoto.Read(imageBytes, 0, imageBytes.Length);
    }

 void GetRequestStreamCallbackx(IAsyncResult asynchronousResult)
        {
            HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
            // End the stream request operation
            Stream postStream = webRequest.EndGetRequestStream(asynchronousResult);
            string img = string.Empty;
            try
            {
                 img = Convert.ToBase64String(imageBytes);
            }
            catch { }
            // Create the post data
         // string postData = "";
             var json="";

              Dispatcher.BeginInvoke(() => json = "{\"emailID\": " + txtemail.Text.Trim() + ",\"pwd\": " + txtpassword.Text + ",\"name\":" + txtname.Text + ",\"img\": " + img + "}");


          byte[] byteArray = Encoding.UTF8.GetBytes(json);

            // Add the post data to the web request
            try
            {
                postStream.Write(byteArray, 0, byteArray.Length);
            }
            catch { }
            postStream.Close();

            // Start the web request
            webRequest.BeginGetResponse(new AsyncCallback(GetResponseCallback), webRequest);
        }

there is any thing wrong in my code. Please Help…

  • 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-01T02:14:58+00:00Added an answer on June 1, 2026 at 2:14 am

    Let me guess: an empty request is being made?

    If you just use Dispatcher.BeginInvoke() to set the json variable, it probably will be set after the Encoding.UTF8.GetBytes(json) call!

    Try it like this:

    void GetRequestStreamCallbackx(IAsyncResult asynchronousResult)
    {
        HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
        // End the stream request operation
        Stream postStream = webRequest.EndGetRequestStream(asynchronousResult);
        string img = string.Empty;
        try
        {
            img = Convert.ToBase64String(imageBytes);
        }
        catch { }
        // Create the post data
        // string postData = "";
        var json = "";
    
        Dispatcher.BeginInvoke(() =>
        {
            json = "{\"emailID\": " + txtemail.Text.Trim() + ",\"pwd\": " + txtpassword.Text + ",\"name\":" + txtname.Text + ",\"img\": " + img + "}";
    
    
            byte[] byteArray = Encoding.UTF8.GetBytes(json);
    
            // Add the post data to the web request
            try
            {
                postStream.Write(byteArray, 0, byteArray.Length);
            }
            catch { }
            postStream.Close();
    
            // Start the web request
            webRequest.BeginGetResponse(new AsyncCallback(GetResponseCallback), webRequest);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to save image data to my sqlite database but I can't do
I want to save an image to the database using SQLite. I send the
I want to save and load my xml data using XmlReader. But I don't
I am working on an ajax-webmethod (using json) to save data in a database
I want to save user image into a database in C#. How do I
I want to extract first frame of uploaded video and save it as image
i want to save and retrieve image path in my application this is my
I've an image. I want to retrieve datas from the database and embed the
I want to create an image database which can be entirely accessed via MATLAB.
Basically i want to store a path to an image into the database Example:I

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.