views:

16

answers:

1

I have a BaseController that all Controllers inherit from. The CaseController has the [Authorize] annotation, so that all controllers require authorization.

But I've just realized that one single controller action must not require authorization. How can I turn off [Authorize] for just that one controller action?

using System.Web.Mvc;
using Unleashed.Service.Interfaces;

namespace Controllers
{
    [Authorize]
    [RequireHttps]
    public class BaseController : Controller
    {
    }
} 

And the controller action is called via a POST from another site. They authorize by passing a token. They will not be authorized via forms authentication.

[Authorize=false] // doesnt compile
[Authorize(false)] // doesnt compile
public ActionResult DoSomething(string token, string data)
{
}
A: 

Solved by creating a new controller that does not inherit from BaseController, and adding the action to that controller. Now this one action does not require authorization, and all existing actions remain as is.

JK