Lets say I have a route like this:
[Route("/users/{Id}", "DELETE")]
public class DeleteUser
{
public Guid Id { get; set; }
}
If I am using CORS with a custom header, an OPTIONS preflight request will be sent out. This will happen on all requests. With the above route, the route will fire, but the OPTIONS will 404 and the ajax error handler will fire.
I could modify the route to be [Route("/users/{Id}", "DELETE OPTIONS")]
but I would need to do this on every route I have. Is there a way to globally allow OPTIONS for all custom routes?
Edit
Since it looks like this behavior is incorrect when a RequestFilter
allows for OPTIONS, I am temporarily using an Subclassed Attribute that just automatically adds OPTIONS to the verbs
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class ServiceRoute : RouteAttribute
{
public ServiceRoute(string path) : base(path) {}
public ServiceRoute(string path, string verbs)
: base(path, string.Format("{0} OPTIONS", verbs)) {}
}