Creating an ASP.NET Web API module in Orchard CMS is simple and straightforward. The following link explains how to do this, and everything works fine. http://www.sebastienros.com/web-api-makes-it-in-orchard
However, GET requests do not work when the WebAPI is running under Orchard and you are using the attribute at the same time [Authorize].
[Authorize]
public IEnumerable<string> Get()
{
return _moduleManager.GetUsers().Select(n => n.UserName);
}
When I call it from the client
HttpClientHandler handler = new HttpClientHandler();
handler.Credentials = new NetworkCredential("user", "password");
HttpClient client = new HttpClient(handler);
var response = await client.GetAsync("http://localhost:30321/OrchardLocal/api/MyWebAPIModule/Users");
Console.WriteLine(response);
the variable responsereturns me an “Not Found” HTML page from Orchard. Without [Authorize]it, it returns a list of users.
Does Orchard have something built-in to match credentials with a registered user in Orchard? Or are there no steps in this process?
source
share