close

 

-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();
        }

arrow
arrow
    文章標籤
    MVC3 權限
    全站熱搜
    創作者介紹
    創作者 chilliwack425 的頭像
    chilliwack425

    無聊的部落格

    chilliwack425 發表在 痞客邦 留言(0) 人氣()