Reputation: 4530
I have a page that is part of a CMS control panel where the user can fill certain textboxes with javascipt code to be saved in a database. The callbacks are being blocked by the server with the following exception:
Exception message: A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$txtMenuAdsenseCode="
I am not exactly sure why the server is complaining about a textbox value when I am not doing a full postback, but is there any way to turn this off? I put ValidateRequest="false"
in the page and this in the web.config
:
<location path="~/Admin/Settings.aspx">
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
</location>
But it is still throwing the exception.
Upvotes: 0
Views: 114
Reputation: 2942
Try serializing the contents of the textbox code to Base64 using Javascript, and then decode from Base64 in your code-behind.
I usually use an extension method such as this:
public static string DecodeFrom64(this string encodedData)
{
var data = Convert.FromBase64String(encodedData);
string result = System.Text.ASCIIEncoding.ASCII.GetString(data);
return result;
}
Upvotes: 1