远程服务器返回错误500内部服务器错误httpwebrequest [英] the remote server returned an error 500 internal server error httpwebrequest

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

问题描述

string  pResponse = "";
try
{
    string ret = string.Empty;

    // Here we create the request and write the POST data to it.
    var request = (HttpWebRequest)HttpWebRequest.Create("http://test.test.net/api/app/postupload?userid=1&rows=[{'epc':'0090720150000000000000003','deployed_time':'9/6/15 12:00:00 AM','sort_time':'9/6/15 12:00:00 AM','harvest_time':'9/6/15 12:00:00 AM','Status':'H '},{'epc':'09009072015000000000000000372','deployed_time':'10/1/15 12:00:00 AM','sort_time':'','harvest_time':'','Status':'D '},{'epc':'0907201500000000000000030','deployed_time':'2/6/15 12:00:00 AM','sort_time':'2/6/15 12:00:00 AM','harvest_time':'','Status':'S '}]");
    request.Method = "POST";
    request.Timeout = 1000000;
    request.UserAgent = ".NET Framework Test Client";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    if (HttpStatusCode.OK == response.StatusCode)
    {
        Stream dataStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        ret = reader.ReadToEnd();
       // login = Newtonsoft.Json.JsonConvert.DeserializeObject<clsgeneral>(ret);
        response.Close();
    }

}
catch (WebException ex)
{
    string strReturn = string.Empty;
    switch (ex.Status)
    {
        case WebExceptionStatus.ProtocolError:
            if (ex is WebException && ((WebException)ex).Status == WebExceptionStatus.ProtocolError)
            {
                var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();

            }
            else
                strReturn = "Protocol error";
            break;
        case WebExceptionStatus.ConnectFailure:
            strReturn = "Connect Failure";
            break;
        default:
            strReturn = new StreamReader(ex.Response.GetResponseStream())
        .ReadToEnd();
            break;
    }
    pResponse = ex.Message.ToString();

}
catch (Exception cc)
{
    pResponse = cc.Message.ToString();

}
finally
{

}







i使用此代码获取错误远程服务器返回错误500内部服务器错误httpwebrequest但我删除了json字符串epc值可以减少工作正常。 r else给出问题...




i am using this code getting error the remote server returned an error 500 internal server error httpwebrequest but i am removing json string epc value can i reduce that working fine. r else giving problem...

推荐答案

看起来你不必提交Post方法而是Get方法,有可能你有什么数据传递查询字符串是不同的,并在服务器上呈现时失败。



正如理查德所解释的那样,不可能说出你从服务器得到的错误没有看到代码。



尝试在浏览器中打开该URL,如果它在服务器上的自定义错误=关闭时失败,那么你可能会看到你得到了什么错误。



http://test.test.net/api/app/postupload?userid=1&rows= [{'epc':'0090720150000000000000003', 'deployed_time':'9/6/15 12:00:00 AM','sort_time':'9/6/15 12:00:00 AM','harvest_time':'9/6/15 12:00: 00 AM','状态':'H'},{'epc':'09009072015000000000000000372','deployed_time':'10/1/15 12:00:00 AM','sort_time':'','harvest_time' :'','状态':'D'},{'epc':'0907201500000000000000030','deployed_time':'2/6/15 12:00:00 AM','sort_time':'2/6/15 12:00:00','harvest_time':'','状态':'S'}]



谢谢

Rushi
It looks like you don't have to submit a Post method but a Get Method, there are likely possibility that what data you are passing in query string is different and failing while rendering on server.

As explained by Richard, it is impossible to say what error are you getting from server without seeing code.

Try to open that URL in browser, if it fails with Custom Error = Off on server then you might see what error are you getting.

http://test.test.net/api/app/postupload?userid=1&rows=[{'epc':'0090720150000000000000003','deployed_time':'9/6/15 12:00:00 AM','sort_time':'9/6/15 12:00:00 AM','harvest_time':'9/6/15 12:00:00 AM','Status':'H '},{'epc':'09009072015000000000000000372','deployed_time':'10/1/15 12:00:00 AM','sort_time':'','harvest_time':'','Status':'D '},{'epc':'0907201500000000000000030','deployed_time':'2/6/15 12:00:00 AM','sort_time':'2/6/15 12:00:00 AM','harvest_time':'','Status':'S '}]

Thanks
Rushi


AEPS响应代码:NA

AEPS消息:响应来自:npci_api BALANCE消息:远程服务器返回错误:(50 0)内部服务器错误。



RRN:

DEVICE TXN:
AEPS RESPONSE CODE: NA
AEPS MESSAGE: Response from :npci_api BALANCE Message :The remote server returned an error: (500) Internal Server Error.

RRN:
DEVICE TXN:


AEPS RESPONSE CODE: NA
AEPS MESSAGE: Response from :npci_api BALANCE Message :The remote server returned an error: (500) Internal Server Error.

RRN:
DEVICE TXN:


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

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