WebAPi接收xml格式數據。解決方案

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";

        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章