WebAPi接收xml格式數據,會出現“從客戶端(messageText="<?xml version="1.0" ...")中檢測到有潛在危險的 Request.Form 值。”
,在Action上面加一個標識 [ValidateInput(false)]即可
[ValidateInput(false)]
[AllowAnonymous]
[HttpPost]
public string ReceiptQuery(string clientid, string key, string messageType, string messageText)
{
if (messageText != "" || messageText != null)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();//新建對象
doc.Normalize();
doc.LoadXml(messageText);//符合xml格式的字符串
}
return "success";
}