GetResponse() 中的 500 内部服务器错误 [英] 500 internal server error at GetResponse()

查看:44
本文介绍了GetResponse() 中的 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个流量很大的 aspx 页面,根据每个用户的请求调用 Web 服务,如下所示.

I have a heavy traffic aspx page calling a web service upon every user`s request as follows.

string uri = "Path.asmx";
string soap = "soap xml string";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("SOAPAction", ""http://xxxxxx"");
request.ContentType = "text/xml;charset="utf-8"";
request.Accept = "text/xml";
request.Method = "POST";

using (Stream stm = request.GetRequestStream())
{
    using (StreamWriter stmw = new StreamWriter(stm))
    {
        stmw.Write(soap);
    }
}
WebResponse response = request.GetResponse();
response.close();

一切正常,但有时我会收到以下错误.

Everything is working fine but sometimes I am getting the following error.

远程服务器返回错误:(500) 内部服务器错误.在 System.Net.HttpWebRequest.GetResponse()

有没有人知道这个错误,或者谁能告诉我我做错了什么.

Does anybody have any idea about this error or can anybody tell me if I am doing wrong.

推荐答案

最后,我使用以下代码摆脱了内部服务器错误消息.不确定是否有其他方法可以实现.

Finally I get rid of internal server error message with the following code. Not sure if there is another way to achieve it.


string uri = "Path.asmx";
string soap = "soap xml string";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("SOAPAction", ""http://xxxxxx"");
request.ContentType = "text/xml;charset="utf-8"";
request.Accept = "text/xml";
request.Method = "POST";

using (Stream stm = request.GetRequestStream())
{
    using (StreamWriter stmw = new StreamWriter(stm))
    {
        stmw.Write(soap);
    }
}

using (WebResponse webResponse = request.GetResponse())
{
}

这篇关于GetResponse() 中的 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆