1. Create a new Article.cs under models
2. Retrofit Account.cs
3. Create a new controller under controllers article
(1) Add two action--limit required login to open
[Authorize]
Public ActionResult ADD ()
{
return View ();
}
[HttpPost]
Public ActionResult Add (models.article art)
{
return View ();
}
4. Download Baidu Editor Ueditor plugin
Http://ueditor.baidu.com/website/download.html
(1) Put the package in the project root directory.
(2) Modify the path in the Umeditor.config.Js path to the plug-in folder in the project
Window. Umeditor_home_url = "/ueditor/";//Modify the local path
(3) Modify the image file upload path in imageup.ashx as needed
String pathbase = "/upload/";
(4) uploader. The attribute "Build action" of the CS class is changed from "compile" to "content".
5. Add view (view)---add.cshtml for the first add
(1) Add JS and CSS references required by ueditor
(2) Instantiation editor
(3) Add the form, the title input box, the Submit button and so on. Contentbody content is as follows:
(4) Retrofit AccountController
1) Logout () plus session["UserID" = null;//New
2) Login added session["UserID" = Acc. First (). id;//New
EF Query Reference:
Http://www.cnblogs.com/liyanwei/p/d9f9b690e71b14bcaf765a92b442e8e9.html
(5) Open the Accountcontext under the DAL
Add field: Public dbset<mvcdemo.models.article> articles {get; set;}
(6) Open Articlecontroller
Add field: Private DAL. Accountcontext db = new DAL. Accountcontext ();
(7) Writing Articlecontroller--add method
MVC Series-11. Two-table syndication-published articles