Code
Protected Void Application_beginrequest (Object sender, eventargs E)
{
// Traverse post parameters, except for hidden fields
Foreach ( String I In This . Request. Form)
{
If (I = " _ Viewstate " ) Continue ;
This . Goerr ( This . Request. Form [I]. tostring ());
}
// Traverse get parameters.
Foreach ( String I In This . Request. querystring)
{
This . Goerr ( This . Request. querystring [I]. tostring ());
}
}
Private Void Goerr ( String TM)
{
If (Sqlfilter2 (TM ))
{
Response. Write ( " Invalid submission! " );
Response. End ();
}
}
Public Static Bool Sqlfilter2 ( String Intext)
{
String Word = " And | exec | insert | select | Delete | update | CHR | mid | master | or | truncate | char | declare | join " ;
If (Intext = Null )
Return False ;
Foreach ( String I In Word. Split ( ' | ' ))
{
If (Intext. tolower (). indexof (I + " " ) > - 1 ) | (Intext. tolower (). indexof ( " " + I) > - 1 ))
{
Return True ;
}
}
Return False ;< BR >}