I am about to create my first proper application in ASP.NET MVC3.
It is basically a jobs site with 3 levels:
1) Users - No registration and can view all jobs posted on the website 2) Posters - Need to register and login to post adverts 3) Admin - Need to register and login to post adverts and review postings before they go live
Would you suggest I use the same Jobs controller for the three levels I mention above? With a LIST action to show jobs to "Users" and a CREATE & EDIT action for 开发者_开发百科the "Posters" & "Admin"?
Thanks Paul
You should enable roles in your application and define 2 of them: 'Admin', 'RegisteredUser'.
You then create 3 controllers. 1 for regular users 1 for Admins 1 for RegisteredUsers.
You can then secure your controllers as follows:
[Authorize(Roles = "Admin")]
public class AdminController : Controller
{
I'd suggest you create a separate Area for Admin with all the functionalities you want for this role and for Users and Posters set different permissions for the Create/Edit actions in your Jobs Controller. You might specify something like this
[Authorization(Roles = UserRoles.Poster)]
public ActionResult Create()
精彩评论