第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Asp.net MVC4:對(duì)控制器和操作均進(jìn)行授權(quán)

Asp.net MVC4:對(duì)控制器和操作均進(jìn)行授權(quán)

動(dòng)漫人物 2019-11-28 09:55:44
如果我在控制器和操作上都具有Authorize屬性,哪個(gè)將生效?還是會(huì)同時(shí)生效?
查看完整描述

3 回答

?
哈士奇WWW

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超6個(gè)贊

我想向覆蓋[授權(quán)]添加一些內(nèi)容(案例2)


OverrideAuthorizeAttribute和DefaultAuthorizeAttribute可以正常工作,但是我發(fā)現(xiàn)您還可以使用OverrideAuthorizationAttribute來覆蓋更高級(jí)別定義的授權(quán)過濾器。


[Authorize(Roles="user")]

public class HomeController : Controller {

    // Available to accounts in the "user" role

    public ActionResult AllUsersIndex() {

        return View();

    }

    // Available only to accounts both in the "user" and "admin" role

    [Authorize(Roles = "admin")]

    public ActionResult AdminUsersIndex() {

        return View();

    }

    // Available to accounts in the "superuser" role even if not in "user" role

    [OverrideAuthorization()]

    [Authorize(Roles = "superuser")]

    public ActionResult SuperusersIndex() {

        return View();

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-11-28
  • 3 回答
  • 0 關(guān)注
  • 675 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)