anonymous and basic authentication problem

From: Tony Wright (
Date: 02/23/04

Date: 22 Feb 2004 19:14:09 -0800


I am having a problem with authentication of a web service. The web
service is a searching service, which returns different results
depending on whether the user is public or trade. Trade users log in,
whereas public users are anonymous.

To access the service, I use the following code
public static FasWebService.FasWS GetFasWebService()
        string UserName = HttpContext.Current.Request.ServerVariables["AUTH_USER"];
        string Password = HttpContext.Current.Request.ServerVariables["AUTH_PASSWORD"];

        if (UserName.Length==0)
                return new FasWebService.FasWS();
                System.Net.NetworkCredential FasCred = new
                System.Net.CredentialCache cache = new System.Net.CredentialCache();
                FasWebService.FasWS ws = new FasWebService.FasWS();
                cache.Add(new Uri(ws.Url),"basic",FasCred);
                return ws;

Tracing through the code, I find that the credentials are being set on
the web service, however inside the web service all it is returning is


I assume it is falling back to anonymous authentication, even though I
am specifying the credentials. The security for the webservice is
Anonymous Authentication AND Basic authentication.

Anyone have suggestions on what is going wrong?