ASP MVC Authorize all actions except a few

前端 未结 7 623
逝去的感伤
逝去的感伤 2020-12-13 00:29

I have a controller and I would like to require Authorization for all actions by default except a couple. So in the example below all actions should require authentication e

7条回答
  •  無奈伤痛
    2020-12-13 01:11

    MVC4 has a new attribute exactly meant for this [AllowAnonymous] (as pointed out by Enrico)

    [AllowAnonymous]
    public ActionResult Register()
    

    Read all about it here:

    http://blogs.msdn.com/b/rickandy/archive/2012/03/23/securing-your-asp-net-mvc-4-app-and-the-new-allowanonymous-attribute.aspx

提交回复
热议问题