public static string NodeUrl(string url)
{
try
{
string databaseName = System.Configuration.ConfigurationManager.AppSettings["NodeServer"];
//string databaseName = ConfigurationManager.ConnectionStrings["NodeServer"].ConnectionString.ToString();
string ur = databaseName + url;
WebRequest request = WebRequest.Create(ur);
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
//Uri uri = new Uri(ur);
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);//此处只是URL不带参数
//request.Method = "POST";
//byte[] buffer = Encoding.ASCII.GetBytes(param);//requestString是你的参数
//request.ContentLength = buffer.Length;//设置数据长度
//Stream stream = request.GetRequestStream();
//stream.Write(buffer, 0, buffer.Length);
//stream.Close();
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Display the status.
Console.WriteLine(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
catch (Exception e)
{
return "";
}
}