1, CKEditor formerly known as FCKeditor, the famous HTML editor, you can edit HTML content online. Our own friends use CKEditor, netizens use Ubbeditor.
Configure the reference documentation to extract the CKEditor (adapters, images, Lang, plugins, skins, themes, ckeditor.js, Config.js, contents.css) to the JS directory, and then " Show all files, "include the CKEditor directory in the project", refer to Ckeditor.js on the posting page, and then set the class= "CKEditor" (CSS Strong) for multiline text boxes (server-side controls cssclass= "CKEditor", The client control sets the cols, rows property, and generally does not use HTML controls directly, and the contents of the editor can still be accessed through the TextBox control's Text property in the code.
Because asp.net the HTML content in the Rich Text editor as an attack content when the page is submitted, you need to set validaterequest= "false" in the page label in ASPX To disable attack detection (2010 also modifies webconfig to disable XSS detection based on error information).
The error encountered is as follows:
* * Modify Webconfig to disable XSS detection
When asp.net commits "<>" to the aspx page, if the phrase "validaterequest=" is not added to the file header, an error occurs: from the client (<?xml version= "... = ' UTF-8 '? ><soap-env:envelope S ...") a potentially dangerous request.form value was detected in the .
If you are a vs2008 user, just at the beginning of the aspx file, as shown in the following article:
Copy Code code as follows:
<%@ Page language= "C #" codebehind= "News_add.aspx.cs" inherits= "Ckeditor.default"%> plus validaterequest= "false" Can.
But if it's VS2010, it's not enough. Also need double hit open web.config, add the following statement between <system.web></system.web>
Copy Code code as follows:
<pages validaterequest= "false"/>
2, Ckfinder is a CKEditor plug-in, used to provide the CKEditor file upload function. Add the CKFinder.dll under Bin\release to the project's references, and unzip the core, Ckfinder.js, ckfinder.html, Config.ascx to the Ckfinder own directory. According to the document modification CKEditor config.js, will upload the processing procedure to set as Ckfinder, attention path problem.
Copy Code code as follows:
Ckeditor.editorconfig = function (config)
{
Define changes to the default configuration here. For example:
Config.language = ' fr ';
Config.uicolor = ' #AADC6E ';
Change to Ckfinder's absolute path, starting from this directory of the site
var Ckfinderpath = "/admin/js";
Config.filebrowserbrowseurl = Ckfinderpath + '/ckfinder/ckfinder.html ';
Config.filebrowserimagebrowseurl = Ckfinderpath + '/ckfinder/ckfinder.html? Type=images ';
Config.filebrowserflashbrowseurl = Ckfinderpath + '/ckfinder/ckfinder.html? Type=flash ';
Config.filebrowseruploadurl = Ckfinderpath + '/ckfinder/core/connector/aspx/connector.aspx?command=quickupload &type=files ';
Config.filebrowserimageuploadurl = Ckfinderpath + '/ckfinder/core/connector/aspx/connector.aspx?command= Quickupload&type=images ';
Config.filebrowserflashuploadurl = Ckfinderpath + '/ckfinder/core/connector/aspx/connector.aspx?command= Quickupload&type=flash ';
};
Using tests, insert hyperlinks, insert pictures, insert files have "upload" l because uploading files is a very dangerous action, so the file will be uploaded when the permissions check. In the Config.ascx of Checkauthentication method lieutenant Colonel Check whether there is permission to upload, return true to have permission, otherwise do not have permissions, generally modified to judge whether the user is logged in, and the user is the user has upload permissions, you can use the session or membership to do.
Copy Code code as follows:
public override bool Checkauthentication ()
{
Warning:do not simply return "true". By doing so, your are allowing
"Anyone" to upload and list the files in your server. You must implement
Some kind of validation here. Even something very simple as ...
//
Return (session["isauthorized"]!= null && (BOOL) session["isauthorized"] = = true);
//
... where session["isauthorized" is set to "true" as soon as the
User logs on your system.
Object obj = session["already logged in"] = true;
if (Obj!=null&convert.toboolean (obj) ==true)
{
return true;
}
Else
{
return false;
}
}
Thinking: How do you realize that only users with a specified IP address can upload?
Copy Code code as follows:
if (request.userhostaddress = = "129.0.0.0.1") {return true;}
In the Setconfig function, set the location of the upload folder BaseURL, the location of the thumbnail, the upload path for each type of data, the file type that is allowed to upload allowedextensions, and so on.