Reputation: 3217
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
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