【发布时间】:2010-07-15 05:10:27
【问题描述】:
我有一个所有控制器都继承自的 BaseController。 CaseController 有 [Authorize] 注解,因此所有控制器都需要授权。
但我刚刚意识到,一个控制器操作不一定需要授权。我怎样才能关闭 [Authorize] 仅针对那个控制器操作?
using System.Web.Mvc;
using Unleashed.Service.Interfaces;
namespace Controllers
{
[Authorize]
[RequireHttps]
public class BaseController : Controller
{
}
}
控制器动作是通过另一个站点的 POST 调用的。他们通过传递令牌进行授权。他们不会通过表单身份验证获得授权。
[Authorize=false] // doesnt compile
[Authorize(false)] // doesnt compile
public ActionResult DoSomething(string token, string data)
{
}
【问题讨论】:
标签: c# asp.net-mvc-2 annotations