使用c#将params设置为Web服务

i can't set params to my web service this is my code in php :

$myValue = $_POST['myValue'];

and this is my C# Code :

void POST(string url, string jsonContent)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "POST";

    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
    Byte[] byteArray = encoding.GetBytes("myValue=" + jsonContent);

    request.ContentLength = byteArray.Length;
    request.ContentType = @"application/json";

    using (Stream dataStream = request.GetRequestStream())
    {
        dataStream.Write(byteArray, 0, byteArray.Length);
    }
    long length = 0;
    try
    {
        //request.GetResponse();
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            length = response.ContentLength;
            using (Stream responseStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                string WSReturned =  reader.ReadToEnd();
            }
        }
    }
    catch (WebException ex)
    {
        //Nothing...
    }
}

i tested "&myValue=" and return null again

This is my PHP Code :

<?php

if (isset($_POST['NewArray'])) {
    $NewArray = $_POST['NewArray'];
} else {
    $NewArray = "Not";
}

echo $NewArray;?>

If you append &myValue=Somethingto your query string you don't use $_POST to get the value but use $_GETinstead.

Now coming to your code it seems okay to me, maybe the error is an another point of your application.

I suggest you to check if there's a value in $_POSTwith isset, and then try to debug it.

If you get an exception then please post the logs, hope it helps :)