I have enabled OutputCache, and are using the following attributes:
[OutputCache]
[ValidateInput(false)]
But I'm getting the following error:
[HttpRequestValidationException (0x80004005): A potentially dangerous Request.QueryString value was detected from the client (pool="lger<br />/for...").]
System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +11933898
System.Web.HttpValueCollection.EnsureKeyValidated(String key) +11932776 System.Web.HttpValueCollection.Get(String name) +23 System.Web.Caching.OutputCacheModule.CreateOutputCachedItemKey(String path, HttpVerb verb, HttpContext context, CachedVary cachedVary) +880 System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs) +803
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +92
Why is this happening? I don't get why the OutputCachedItemKey needs to validated? Any way how to disable this?
Note that it only goes wrong with enabling the OutputCache.
Without everything works fine.
Update It seems really easy reproduciable:
- Start new ASP.NET Project with ASP.NET MVC template (4.5.2)
- Add
[OutputCache( Duration = 1)]
- run http://localhost:(port)/?test=%3Cscript%3E
Result: Potentially dangerous request, despite that you do anything with this parameter.