I. Preparation of documents
1. Download the official version of Ueditor. Delete the back-end files. Keep the Config.json file in the back-end folder
2. Search for Ueditornetcore in NuGet Manager, get the project address, download the source code
: Https://github.com/sankeyou/UEditorNetCore
Second, use the reference document: http://www.cnblogs.com/durow/p/6116393.html
1. Startup.cs Injection Ueditor Service
Public void configureservices (iservicecollection services) { // parameter 1 is a configuration file path, default is Project directory under config.json/// parameter 2 parameter for cache profile, default false Services. Addueditorservice (); Services. Addmvc (); }
2. Adding a controller to process requests from ueditor
[Route ("Api/[controller]")] Public class Ueditorcontroller:controller { private ueditorservice UE; Public Ueditorcontroller (ueditorservice UE) { this. UE = UE; } Public void Do () { UE. DoAction (HttpContext); } }
Note: The address of the route should be serverurl consistent in the Ueditor.config.js configuration.
3. Copy the previously reserved config.json files to, using the editor's website root directory, modify the upload operation configuration pathformat and prefix. For example:
Three. About the upload save path. Because downloaded the source code, I was directly in the source code modification. Store to a different folder
Open the downloaded source code:
1. Modify the Uploadimageaction,uploadscrawlaction,uploadvideoaction,uploadfileaction method for the selected class. For example:
Private voidUploadimageaction (HttpContext context) {NewUploadhandler (Context,NewUploadconfig () {AllowExtensions= Config.getstringlist ("Imageallowfiles"), //Pathformat = config.getstring ("Imagepathformat"),Pathformat = Guid.NewGuid (). ToString (),//Modify the way the file name is generated, I use the GUID directlySizeLimit = Config.getint ("imagemaxsize"), Uploadfieldname= Config.getstring ("Imagefieldname"), Savefilepath= Config.getstring ("Imagesavefilepath")//A new parameter is used to get the save path, new configuration item in config file }). Process (); }//the modified
Private voidUploadimageaction (HttpContext context) {NewUploadhandler (Context,NewUploadconfig () {AllowExtensions= Config.getstringlist ("Imageallowfiles"), Pathformat= Config.getstring ("Imagepathformat"), SizeLimit= Config.getint ("imagemaxsize"), Uploadfieldname= Config.getstring ("Imagefieldname") }). Process (); }//before modification
Modified configuration Content
2. Modify the selected class in the diagram. Replace save file with Config.webrootpath path
3. Copy the picture that you pasted in the editor from another site if you want to save it locally. Modify the selected file and modify the Ueditor.config.js configuration if not saved
. Net Core uses Baidu Ueditor editor