System.Web.HttpRequestValidationException が発生したときにスタック トレースを分析すると、それをスローしているコードを見つけることができます。
System.Web.HttpRequestValidationException (0x80004005): 潜在的に危険な Request.Form 値がクライアントから検出されました (IdentifierTextBox="
System.Web.HttpRequest.ValidateString (文字列値、文字列 collectionKey、RequestValidationSource requestCollection) で
Reflector を使用すると、ValidateString が次の呼び出しを行っていることがわかります。
internal static bool IsDangerousString(string s, out int matchIndex)
{
matchIndex = 0;
int startIndex = 0;
while (true)
{
int num2 = s.IndexOfAny(startingChars, startIndex);
if (num2 < 0)
{
return false;
}
if (num2 == (s.Length - 1))
{
return false;
}
matchIndex = num2;
char ch = s[num2];
if (ch != '&')
{
if ((ch == '<') && ((IsAtoZ(s[num2 + 1]) || (s[num2 + 1] == '!')) || ((s[num2 + 1] == '/') || (s[num2 + 1] == '?'))))
{
return true;
}
}
else if (s[num2 + 1] == '#')
{
return true;
}
startIndex = num2 + 1;
}
}