I need to save HTML text on a cookie and i’m getting System.Web.HttpRequestValidationException.
I’ve tried:
Adding <httpRuntime targetFramework="4.8.1" requestValidationMode="2.0" />
to my web.config
file and <%@ Page validateRequest="false"
to my .aspx file.
Encoding the text
HttpCookie template_html_cookie = new HttpCookie("template_html_cookie");
template_html_cookie.Value = HttpUtility.UrlEncode(template.body);
Response.Cookies.Add(template_html_cookie);
and then
string template_html = HttpUtility.UrlDecode(Request.Cookies["template_html_cookie"].Value);