I have an ASP.NET MVC 3 application with Windows authentication. Now I've added the web api to it (nuget package) and want anonymous access (later on I'll add an api key). But I haven't managed to get it to work.
All my WEB API controllers are under the "/api" path, and none of them have the Authorize attribute.
Here's my current web.config (I removed all the bits and pieces that are irrelevant to this matter):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authentication mode="Windows" />
<httpRuntime maxRequestLength="102400" requestPathInvalidCharacters="<,>,*,:,&,\" />
<authorization>
<deny users="?" />
</authorization>
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="..." applicationName="..." />
</providers>
</roleManager>
<profile enabled="false" defaultProvider="AspNetProfileProvider">
<providers>
<clear />
<add name="AspNetProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="..." applicationName="..." />
</providers>
<properties></properties>
</profile>
<customErrors mode="RemoteOnly" defaultRedirect="~/Error/Generic">
<error statusCode="404" redirect="~/Error/NotFound" />
<error statusCode="403" redirect="~/Error/AccessDenied" />
</customErrors>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<security>
<requestFiltering allowDoubleEscaping="true"></requestFiltering>
</security>
</system.webServer>
<location path="Error">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Scripts">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="api">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>
All my requests are getting "HTTP Error 401.2 - Unauthorized", but when I enter some valid windows credentials then the request executes successfully.
So, how can I disable the windows authentication for my WEB API? thanks in advance.