Json查询:停止工作

时间:2014-12-02 13:57:10

标签: c# json httprequest

一个月前我做了这个小程序:

            input = "20032608";
            string url = "http://ion.inapi.cl:8080/Patente/ConsultaAvanzadaPatentes.aspx/GetCaratula";
            Uri uri = new Uri(url);
            HttpWebRequest request = HttpWebRequest.Create(url) as System.Net.HttpWebRequest;

            request.ContentType = "application/json; charset=utf-8";
            request.Method = "POST";
            var postData = JsonConvert.SerializeObject(new { Sol_Nro = input, Ori = 1 });
            var data = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = data.Length;

            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            request.Timeout = System.Threading.Timeout.Infinite;

            WebResponse response = request.GetResponse();

然而,有一天它停止工作,返回500内部服务器错误。这是JS的源代码:

http://ion.inapi.cl:8080/Patente/js/ConsultaAvanzadaPatentes.js

我不确定问题是否与新参数'Ori'有关。

我尝试将postdata修改为:

var postData = JsonConvert.SerializeObject(new { Sol_Nro = input, Ori = 1 });

但是,现在我收到500内部服务器错误。 有什么想法吗?

这是方法GetCaratula。我只会发布相关部分:

function getCaratula(sol_nro, ori) {
    var params = new Object();
    params.Sol_Nro = sol_nro;
    params.Ori = ori;

    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "ConsultaAvanzadaPatentes.aspx/GetCaratula",
        data: JSON.stringify(params),
        dataType: "json",
        async: true,
        cache: false,
        success: function (data, textStatus) {
            if (textStatus == "success") {
                var obj = $.parseJSON(data.d);

                if (obj.ErrorMessage == null) {

....

        error: function (request, status, error) {
            alert($.parseJSON(request.responseText).Message);
        }
    });    
}

0 个答案:

没有答案