When I attempt to connect to an intranet web service from a web application running on IIS Express that web service returns a 403 Forbidden. The service works correctly when I access via unit tests or from the same site running on Cassini or on under IIS 7.5 on my server. My gut tells me this is a configuration issue, but I'm not sure where to begin looking.
What would cause a remote web service to return a 403 Forbidden when that service is accessed from a site running on IIS Express?
To clarify the service I am accessing is not SOAP based. I am setting up a specific network credential and passing it along with my request which the below code illustrates.
protected XDocument Search(Uri requestUri)
{
var nc = new NetworkCredential(this.config.ServiceUserName,
this.config.ServicePassword);
var cCache = new CredentialCache();
cCache.Add(requestUri, "Basic", nc);
var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.Credentials = cCache;
request.PreAuthenticate = true;
request.Method = WebRequestMethods.Http.Get;
var response = (HttpWebResponse)request.GetResponse();
return XDocument.Load(new StreamReader(response.GetResponseStream()));
}
I do not have time to dig into the why right now, but I can say that it had something to do with my proxy settings. Switching to a different proxy provider for my box alleviated the issue. This internal transaction should have been bypassing the proxy all together and why IIS would behave differently than other mechanisms is beyond me. Begrudgingly I am going to mark this as the answer and hope the small notice to check your proxy settings helps someone. Sorry this isn't more specific.