mahesh
mahesh

Reputation: 3217

How to implement Authorization in ASP.NET Web API using Windows Azure

I have sample ASP.NET Web API with get method, I have prefixed a [Authorize] attribute on top of the method. Can I please know how should I call this method from browser or fiddler? Also, I am hosting these API's on Windows Azure

public class ValuesController : ApiController
{
    // GET api/values
    [Authorize]
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }
}

Upvotes: 0

Views: 1239

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039378

Depending on the type of authorization you are using there might be different ways. But if you are using default routing you could call your method at the following url:

/api/values

You might of course need to pass additional headers depending on the authorization mechanism you choose. The [Authorize] attribute doesn't do anything unless you have configured some authorization. You may take a look at the following article for an example of how you could use tokens to authenticate your users.

Upvotes: 1

Related Questions