前几天给一个客户换了server随后就出现了如下报错问题远程服务器返回错误: (500) 内部服务器错误。这是部分代码
try
{
/*** REQUEST TO HQ ***/ // Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("地址");
// Set the Method property of the request to POST.
request.Method = "POST"; // Create POST data and convert it to a byte array.
string postData = "table=InventoryUpdate&xml=" + ss + "&storeId=5";
byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length; // Get the request stream.
Stream dataStream = request.GetRequestStream(); // Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object.
dataStream.Close(); /*** RESPONSE FROM HQ ***/ // Get the response.
WebResponse response = request.GetResponse(); // Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server.
dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream); // Read the content.
responseFromServer = reader.ReadToEnd(); // Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
} catch (WebException ex)
{
ex.ToString();
}
return responseFromServer;
将客户地址转到我们的测试服务器上又可以用了,估计是服务器配置问题。求大牛们指正
try
{
/*** REQUEST TO HQ ***/ // Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("地址");
// Set the Method property of the request to POST.
request.Method = "POST"; // Create POST data and convert it to a byte array.
string postData = "table=InventoryUpdate&xml=" + ss + "&storeId=5";
byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length; // Get the request stream.
Stream dataStream = request.GetRequestStream(); // Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object.
dataStream.Close(); /*** RESPONSE FROM HQ ***/ // Get the response.
WebResponse response = request.GetResponse(); // Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server.
dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream); // Read the content.
responseFromServer = reader.ReadToEnd(); // Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
} catch (WebException ex)
{
ex.ToString();
}
return responseFromServer;
将客户地址转到我们的测试服务器上又可以用了,估计是服务器配置问题。求大牛们指正
解决方案 »
- 如何确定dataGridView1_CellClick事件是否发生?
- 20分在线求C# 如何在一张图上设置热区域
- 请问这是什么格式的XML,如何在WINFROM代码中进行读取存到数据库中
- 俺笨笨,来问两个用DataAdapter更新DataSet的问题
- 如何将子窗体中的数据传回父窗体(简单问题啊,我搞了两天了,在线等)
- (不知道该不该在这儿发)如何让应用程序的一个程序段运行在另一个应用程序的线程中
- 关于跨AppDomain传递Form的问题
- ????那位高手会使用Microsoft.VisualBasic.Compatibility.VB6.ADODC !!!!在线等待100高分
- C#:读取和写回自定义格式文件内容,求代码
- 在C#中调用java,急!
- 想将一个变量值存在文件中是用ini方式好呢还是app.config方式好呢?
- C# 一个二维数组读取截取字符串的问题
WebResponse response = request.GetResponse();
会报错