A potentially dangerous Request.Form value was detected from the client

前端 未结 30 2160
刺人心
刺人心 2020-11-21 05:24

Every time a user posts something containing < or > in a page in my web application, I get this exception thrown.

I don\'t want to go

30条回答
  •  孤独总比滥情好
    2020-11-21 05:46

    I ended up using JavaScript before each postback to check for the characters you didn't want, such as:

    
    
    function checkFields() {
        var tbs = new Array();
        tbs = document.getElementsByTagName("input");
        var isValid = true;
        for (i=0; i') != -1) {
                    alert('<> symbols not allowed.');
                    isValid = false;
                }
            }
        }
        return isValid;
    }
    

    Granted my page is mostly data entry, and there are very few elements that do postbacks, but at least their data is retained.

提交回复
热议问题