Я следую примеру на http://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator.aspx, но, похоже, он не работает, и я все еще получаю ошибку.Вот мой класс и как я могу добавить его в webconfig
мой webconfig:
<httpRuntime requestValidationType="CustomRequestValidation"/>
мой класс:
public class CustomRequestValidation : RequestValidator
{
public CustomRequestValidation() { }
protected override bool IsValidRequestString(HttpContext context, string value, RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)
{
validationFailureIndex = -1;
if (requestValidationSource == RequestValidationSource.Path)
{
// value "&","=" allowed.
if (value.Contains("&") || value.Contains("="))
{
validationFailureIndex = -1;
return true;
}
else
{
//Leave any further checks to ASP.NET.
return base.IsValidRequestString(context, value, requestValidationSource, collectionKey, out validationFailureIndex);
}
}
else
{
return base.IsValidRequestString(context, value, requestValidationSource, collectionKey, out validationFailureIndex);
}
}
}
Подробности ошибок:
System.Web.HttpException
A potentially dangerous Request.Path value was detected from the client (=).
System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (:).
at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
at System.Web.HttpApplication.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)