I have an application on our intranet that is configured for Anonymous Authentication that needs to consume a web service configured for Windows Authentication.
I have added the following section to the web.config file to allow anonymous access on just the web service:
<location path="services/MyApi.asmx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
When I try to consume the web service from the application with anonymous access, I get the following error:
The request failed with HTTP status 401: Unauthorized.
Here is my source code for consuming the web service:
using (MyService.MyApi proxy = new MyService.MyApi())
{
string employeeId = Session["EmpCode"].ToString();
proxy.MyMethod(employeeId);
}
What do I need to do to resolve this error?