I do not believe that you can force the browser to preempt 401. When the request for your service is executed, the service responds with HTTP 401 and adds the WWW-Authenticate Basic header, as well as, I assume, an area (which you can define).
It would be helpful to take a look at the RFC for basic authentication, which details how basic authentication standards should be applied. http://www.ietf.org/rfc/rfc2617.txt
You can also explore your own HTTP module, which should provide you with more flexibility in your application and how you deal with basic authentication. This allows you to register event handlers for authentication and request completion events and dictate with greater clarity how your service will work with basic auth. A primer for this is available on the asp.net website. http://www.asp.net/web-api/overview/security/basic-authentication
If your services use different authentication based on the verification of your applications (for example, the service will only use basic authentication when the application is configured to authenticate forms), than using the HTTP module will allow you to conditionally use basic authentication. I usually register handlers in this scenario as follows:
AuthenticationSection config = (AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication"); if(config.Mode == AuthenticationMode.Forms) { module.Authenticate += OnEnter; context.EndRequest += OnLeave; }
source share