0
这是现在破坏了我的大脑一段时间。当我发布一个较小的XML字符串时,代码工作正常。只要我添加更多XML节点并发布,我就会得到臭名昭着的'404错误'C#WebClient 404错误大字符串
我将XML数据作为字符串发布到C#中的通用处理程序。
string strXML = "Large XML Content Here";
WebClient client = new WebClient();
string xmlResult = "";
try
{
xmlResult = client.DownloadString(_workContext.AccountingWebServiceLink
+ "?action=updateprimary&xml="
+ System.Web.HttpUtility.UrlEncode(strXML));
}
catch(Exception e)
{
System.IO.File.AppendAllText(Server.MapPath("~/addressXMLReturnError.txt"),
"Error: " + e.Message + " returnValue = " + xmlResult);
}
我认为这可能与服务器不接受大字符串有关吗?
这可能是限制,以便尝试'<的httpRuntime maxUrlLength =“XXX” />'你的web.config应用程序,但我认为这种情况下的错误是不同的。 –
@PawełŁukasik我现在就试试看看它是否有所作为。仅供参考:我发布的字符串长度为1562长 – Orion
如果您有权访问您要发送XML的服务器的代码,我建议您进行HTML POST,并在编码后将XML放入主体中作为BASE64。 https://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340 –