I have a web api 2.0 setup which calls a remote url internally and this code works great with PC's but not with Apple Mac browsers such as FireFox; they are getting a 401 error. Any help will be appreciated!
The code in question is:
private static XmlDocument GetXml(string searchCriteria)
{
if (searchCriteria == null) throw new ArgumentNullException(nameof(searchCriteria));
var sUrl = "https://a_remote_classic_asp_service_layer/service.asp?";
var appendUrl = "&sh=N&sp=Y&sr=N";
string fullUrl = $"{sUrl}{searchCriteria}{appendUrl}";
string searchParms = $"{searchCriteria}{appendUrl}";
var document = new XmlDocument();
document.PreserveWhitespace = false;
using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
{
var request = WebRequest.Create(fullUrl);
request.Credentials = CredentialCache.DefaultCredentials;
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
using (var stream = request.GetResponse().GetResponseStream())
{
if (stream == null) return document;
using (var reader = XmlReader.Create(stream))
{
document.Load(stream);
}
}
}
return document;
}
Thanks!
Ok, got this figured out. Each browser had to be configured differently on the Apple Mac's and these configuration updates will be pushed out in scripts to fix the issues. Tested this on my OSX Mavericks version and all browsers (Safari, Chrome, Firefox) worked fine.