会社のイントラネットで動作する WebAPI Web サービスと Web サイトをセットアップしようとしています。IIS を使用して Web サービス (A) と Web サイト (B) をホストしています。私の Web サイトのページは、次のように Web サービスにリクエストを送信します。
var URL = 'http://MachineName:80/AWebService/api/GetGuid';
var request = new XMLHttpRequest();
request.open("GET", URL, false);
request.withCredentials = "true";
request.send();
var response = request.responseText;
return response;
WebService コードは次のようになります。
[EnableCors(origins: "http://localhost", headers: "*", methods: "*")]
public class StoneSoupController : ApiController
{
[ActionName("GetGuid")]
public HttpResponseMessage GetGuid()
{
var indenty = this.User.Identity;
Guid g = Guid.NewGuid();
HttpResponseMessage msg = new HttpResponseMessage();
msg.Content = new StringContent(g.ToString());
msg.Headers.Add("Access-Control-Allow-Origin", "http://localhost"); //tried with and without this
msg.Headers.Add("Access-Control-Allow-Credentials", "true"); //tried with and without this
return msg;
}
}
IIS で Web サービスの認証モードを匿名認証に設定すると、Web サービスは期待どおりに GUID 文字列を返します。ただし、どのユーザーが Web サービスの特定のメソッドにアクセスできるかを制御する必要があり、Windows 資格情報を使用してこれを行う必要があります。
私の問題は、Firefox に Windows 資格情報を送信させることができないように見えることです。Firefoxに inhttp://localhost
を含めようとしましたが、効果がないようです。network.automatic-ntlm-auth.trusted-uris
about-config
IIS でのログ記録を有効にしましたが、これが要求の記録です
2013-08-01 21:36:05 136.203.40.232 GET /AWebService/api/GetGuid - 80 - 136.203.40.232 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:17.0)+Gecko/20100101+Firefox/17.0 200 0 0 965
ご覧のとおり、トランザクションにはユーザー ID がありません。
誰でもこれで私を助けることができますか?