Adr*_*zki 9 authentication authorization asp.net-mvc-3
是否有一种方法可以在具有Authorize属性的控制器类中的一个操作中忽略[Authorize]属性?
[Authorize]
public class MyController : Controller
{
[Authorize(Users="?")]//I tried to do that and with "*", but unsuccessfuly,
public ActionResult PublicMethod()
{
//some code
}
public ActionResult PrivateMethod()
{
//some code
}
}
Run Code Online (Sandbox Code Playgroud)
只需要PrivateMethod()就可以进行身份验证,但也需要它.
PS:我不想制作我的自定义授权过滤器.
[]的
Erf*_*fan 16
你可以使用[AllowAnonymous]
[Authorize]
public class MyController : Controller
{
[AllowAnonymous]
public ActionResult PublicMethod()
{
//some code
}
public ActionResult PrivateMethod()
{
//some code
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14555 次 |
| 最近记录: |