开发者

ActionMethodSelectorAttribute + AllowHtml

开发者 https://www.devze.com 2023-03-22 05:20 出处:网络
I have an ActionMethodSelectorAttribute which i have the following line in: var req = controllerContext.RequestContext.HttpContext.Request.Form.AllKeys.Any() ? controllerContext.RequestContext.HttpC

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消