How to protect ASP.NET Web API 2

I need to implement ASP.NET Web API 2 ie

[RoutePrefix("orders")] 
public class OrdersController : ApiController 
{ 
    [Route("{id}")] 
    public Order Get(int id) { } 
    [Route("{id}/approve")] 
    public Order Approve(int id) { } 
} 

I am wondering how this can be protected?

Can we use ASP.NET ID for this, for example?

Any clue?

+4
source share
2 answers

You can add an attribute [Authorize]to the class, and then send the basic authentication information through the header.

+4
source

AuthorizeAttribute, ASP.NET, -API. ASP.NET SimpleSecurity Project. AuthorizeAttribute. , . . - . SimpleMembership, Identity ASP.NET.

+2

All Articles