A potentially dangerous Request.Form value was detected from the client
Questo errore capita quando si cercano di inviare dei dati html in una POST:
uno dei modi per evitarlo è usare Unvalidate:
System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (data="...ription":"<p>test</p>","bloc...").
at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.<>c__DisplayClass1.<ValidateHttpValueCollection>b__2(String key, String value)
at System.Web.HttpValueCollection.EnsureKeyValidated(String key)
at System.Web.HttpValueCollection.Get(String name)
at System.Collections.Specialized.NameValueCollection.get_Item(String name)
at Sgart.API.RequestController.<PostFormDataInsert>d__0.MoveNext() in c:\Users\xxx\Documents\Visual Studio 2012\Projects\P1\P2\API\RequestController.cs:line 102
l'istruzione che sollevava l'eccezione era:at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.<>c__DisplayClass1.<ValidateHttpValueCollection>b__2(String key, String value)
at System.Web.HttpValueCollection.EnsureKeyValidated(String key)
at System.Web.HttpValueCollection.Get(String name)
at System.Collections.Specialized.NameValueCollection.get_Item(String name)
at Sgart.API.RequestController.<PostFormDataInsert>d__0.MoveNext() in c:\Users\xxx\Documents\Visual Studio 2012\Projects\P1\P2\API\RequestController.cs:line 102
C#
string dataString = HttpContext.Current.Request.Form["data"];
C#
string dataString = HttpContext.Current.Request.Unvalidated.Form["data"];