即使服务完成了业务,调用ashx服务也会返回500内部服务器错误

时间:2018-05-05 13:35:40

标签: c# web-services ashx

我在第三方创建用户时调用ashx服务,我设置了URL和查询字符串参数。请求接受POST / GET http方法,响应应该将响应代码和响应文本作为xml返回。

奇怪的是用户正在创建,但响应会引发异常[500内部服务器错误]。

以下是代码:

string URI = "https://thirdpartyservice.com/ApiHandler.ashx?";
string params = "ptf_cmd=403&ptf_method=md5" +
            "&ptf_timer=" + sTimer +
            "&ptf_check=" + sCheck +
            "&ptf_client=" + rsaClient +
            "&ptf_partner=" + sPartner +
            "&ptf_offername=" + offername +
            "&ptf_host=" + rsaHost +
            "&ptf_login=" + sLogin +
            "&ptf_password=" + password +
            "&ptf_firstname=" + firstName +
            "&ptf_lastname=" + lastName +
            "&ptf_email=" + userEmail +
            "&ptf_interfacelanguage=" + rsaInterfaceLanguage +
            "&ptf_role=" + rsaUserRole +
            "&ptf_pupildiscipline=" + rsaPupilDiscipline +
            "&ptf_detailedResult=1" +
            "&ptf_endingurl=" + rsaReturnUrl +
            "&ptf_admingroup=" + rsaAdminGroup +
            "&ptf_pedagroup=" + rsaPedaGroup +
            "&ptf_usercreationmode=API";
            using (var wc = new WebClient())
            {
                wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";  
                string xmlResult = wc.DownloadString(URI + params); //throws exception [500 Internal Server Error].
                //string xmlResult = wc.UploadString(URI, params);//throws exception [500 Internal Server Error].
            }

我在没有设置标题和POST / GET的情况下尝试了请求,但也引发了异常。 我还使用HttpWebRequest类发送请求但它失败了。有任何建议如何处理?

0 个答案:

没有答案