Scenario
- I have an Api 2.2 RESTful service made with VS2012 C #
- I use basic authentication with user user / password verification (works fine)
- Some methods have an attribute
[AllowAnonymous] - Several methods use
[Authorize(Roles = "myRol")] - In local works (read the user and go through, check it using the database, deny or allow, when necessary, allow anonymity, when necessary, etc.)
Problem
When I first opened the service in the DEV environment, I was unable to log in:
- Ways with AllowAnonymous return
200 - Basic Security Methods
401
Data (please request or comment on this update)
This is my web.config:
<system.webServer> <modules> <add name="BasicAuthHttpModule" type="WebHostBasicAuth.Modules.BasicAuthHttpModule, myAssemblyName" /> </modules>
This is my header (it works in local mode):
Authorization: Basic YXR1cG9uZTp0ZXN0 Content-Type: application/json; charset=utf-8
and this is my answer:
Status 401 Unauthorized
Data : {"message":"Authorization has been denied for this request."}
Title :
Pragma: no-cache Date: Fri, 24 Apr 2015 14:36:27 GMT Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Content-Type: application/json; charset=utf-8 Cache-Control: no-cache Content-Length: 61 Expires: -1
This is my IIS configuration (if I set to " on " Basic Authentication, IIS will ask me to provide credentials that I donβt have and / or they are invalid):

Question:
Is it well configured? Did I miss something?
How can I see a log or something about what is the internal error of this?
Thanks in advance.
source share