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

  • Home
  • SEARCH
  • 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 6792675
In Process

The Archive Base Latest Questions

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

I would retrive the Return value from a function php to a C# WinApp

  • 0

I would retrive the Return value from a function php to a C# WinApp Client.

I have some functions in a php page.
Those functions use Get Method and elaborate some data recived from a C# Winapp Client.

So php pages after elaborate the data return a value. Now i would get this value from C# client.

I would do this ‘on fly’ without save any files on the Pc Client.

how can I do this?

Edit : If someone Could make an exampe with Json or XML i will appreciate it.

  • 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-26T18:00:00+00:00Added an answer on May 26, 2026 at 6:00 pm

    A simple example with JSON output:

    PHP code:

    <?php 
    #header('content-type:application/json');
    if(array_key_exists("foo", $_POST) && !empty($_POST["foo"])) {
       $data = array('foo' => 'baa', 'x' => 'y', 'sucess' => 'true', 'error' => 'null');
    }
    else {
        $data = array('error' => 'foo is empty', 'sucess' => 'false');
    }
    
        die(json_encode($data));
    ?>
    

    C#.NET code:

    using System;
    using System.Text;
    using System.Net;
    using System.IO;
    using System.Web.Script.Serialization;
    
    namespace App
    {
        class Program
        {
            static void Main(string[] args)
            {
                string response = DoRequest();
                JavaScriptSerializer ser = new JavaScriptSerializer();
                View json = ser.Deserialize<View>(response);
                if (json.sucess)
                {
                    // do something.. 
                }
                else
                {
                    Console.WriteLine("Erro:{0}", json.error);
                }
    
            }
    
            static string DoRequest()
            {
                string domain = "..."; // your remote server 
                string post = "foo=baa";
                byte[] data = Encoding.ASCII.GetBytes(post);
    
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(domain);
                request.Method = "POST";
                request.Referer = "desktop C# Application";
                request.ContentLength = data.Length;
                request.ContentType = "application/x-www-form-urlencoded";
    
                Stream stream = request.GetRequestStream();
                stream.Write(data, 0, data.Length);
    
                HttpWebResponse response = (HttpWebResponse) request.GetResponse();
                StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                char[] buffer = new char[256];
                int count;
                StringBuilder buf = new StringBuilder();
                while ((count = sr.Read(buffer, 0, 256)) > 0)
                {
                    buf.Append(buffer, 0, count);
                }
    
                response.Close();
                stream.Close();
                sr.Close();
    
                return buf.ToString();
    
            }
        }
    
        public class View
        {
            public string foo { get; set; }
            public string x { get; set; }
            public bool sucess { get; set; }
            public string error { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function from which I would like to return a value as
In several places I have to retrieve some value from a dict, but need
I have a function which must return one dimensional associate array, like $user_info[$index]=value where
I have an ashx page that returns the following JSON data that I would
It seems there are different ways the __repr__ function can return. I have a
I have a function searchWorkByName that takes key as an argument and use SQOL
I have a simple admin I'm creating for a client using PHP and Mysql.
So I have a C++ application that takes a value from a key in
I use this simple method to retrieve a Query String from a Page a
I would like to retrieve the AppSetting key from the assembly config file called:

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.