MVC Series-11. Two-table syndication-published articles

Source: Internet
Author: User

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

Related Article

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.