To do this for webapi you can use the below in your Web.Config
<location path="api">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
This is saying that for the api controllers, allow any users (denoted by the ?). It might be worth changing that to be more specific if you wanted to do specific controllers.
It also assumes you deny access to all anonymous users and that your web.config authentication is like this
<system.web> <authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization> </system.web>
However if you want to allow it on the MVC Controllers you can utilise the
[AllowAnonymous] attribute.
Related:
Use Anonymous authentication in MVC4 on single controller when the whole application uses Windows Authenticaion
Disable Windows Authentication for WebAPI
Windows Authentication for ASP.NET MVC 4 - how it works, how to test it
Additional Reading:
Windows Authentication ASP.NET
Authorize Attribute MSDN
Anonymous Attribute MSDN