-1) in _layout.cshtml
<div id="menucontainer">
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
</ul>
</div>
0) Only Administrator can use Customer Function (just put the Authorize before the class declaration)
[Authorize(Roles = "Administrator")]
public class CustomerController : Controller
{
private CustomerOrderDB db = new CustomerOrderDB();
//
// GET: /Customer/
[Authorize(Users="chilliwack,asdf1")]
public ViewResult Index()
{
return View(db.Customers.ToList());
}
1) 只有特定的使用者可以使用List功能
//
// GET: /Customer/
[Authorize(Users="username1,username2")]
public ViewResult Index()
{
return View(db.Customers.ToList());
}
//
// GET: /Customer/Details/5
public ViewResult Details(int id)
{
Customer customer = db.Customers.Find(id);
return View(customer);
}
2) 只有特定群組可以使用Create功能
//
// GET: /Customer/Create
[Authorize(Roles="Administrator")]
public ActionResult Create()
{
return View();
}