I have an ActionMethodSelectorAttribute which i have the following line in:
var req = controllerContext.RequestContext.HttpContext.Request.Form.AllKeys.Any() ? controllerContext.RequestContext.HttpContext.Request.Form : controllerContext.RequestContext.HttpContext.Request.QueryString;
However - this spews up when the form is posting HTML content.
Now - I do have AllowHtml on the InputModel being posted and the action itself does have ValidateInput(false)
I suspect the issue is that we haven't gotten that far down the pipeline yet
anyone know how to allow this 开发者_JAVA百科for this filter?
AllowHtml
works only for the model binder IIRC and for ValidateInput
is too soon because it is not yet certain which action will be executed. I was solving this issue few days ago and after some digging I found ValidationUtility
in Microsoft.Web.Infrastructure.DynamicValidationHelper
:
Func<NameValueCollection> formGetter;
Func<NameValueCollection> queryStringGetter;
ValidationUtility.GetUnvalidatedCollections(HttpContext.Current, out formGetter, out queryStringGetter);
var form = formGetter();
var queryString = queryStringGetter()
It's not really pretty, but it works :) Also note that ValidationUtility is hidden from intellisense.
精彩评论