2
votes

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?

1
What framework are you using?James
So that resources would require me to change my asmx service to WCF service?Michael Kniskern
The next step is to see what is denying access, check this out: (blogs.msdn.com/b/david.wang/archive/2005/07/14/…)James
Not necessarily, it is more as a reference at this point in time. But also change to reflect this: <allow users="*" />James

1 Answers

0
votes

change ? for * in <allow users="*" /> it will be allow an Anonymous user to the webservice