By default, Asp.net does not allow the submission of HTMLSource codeTo a large extent, this prevents cross-site (COMMIT) attacks. However, Rich Text editors such as ckeditor and FCKeditor must generate HTML sources.Code, How to solve this conflict?
The general method is to modify web. config.
ASP. net2.0/3/3.5:
<PagesValidaterequest = "false"> </Pages>
In ASP. net4.0, this is not enough. It must be written as follows:
<Pages validaterequest = "false"> </pages>
<HttpruntimeRequestvalidationmode = "2.0"/>
This solution solves the problem, but also reduces security. How can we use ckeditor/FCKeditor without reducing the default security of Asp.net?
Ideas:
Add a hidden field to the client-form. When submitting a request, use URL encoding for the ckeditor/fck content, assign the value to the hidden field, clear ckeditor/fck, and submit the file, in this way, the submitted content does not contain the HTML source code.
Server-receives the value of this hidden domain as the content of the ckeditor, and decodes the URL before receiving it.
Code:
<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. cs" inherits = "ckeditor_demo.default" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">