. Net Core uses Baidu Ueditor editor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.