나는 ajax (angularJs하지만 jQuery도 시도했다.)를 통해 서버를 호출하고있다. 응답에 쿠키가 포함되어 있지만 어떤 이유로 쿠키가 클라이언트에 저장되지 않습니다. 응답에 Set-cookie 헤더가 표시되지만 Chrome의 개발 도구에 쿠키가 표시되지 않으며 서버의 후속 요청에서 쿠키가 표시되지 않습니다.Ajax 요청, 무시 된 쿠키?
이HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Headers.AddCookies(new[] { new CookieHeaderValue("auth", "my cookie content") { Expires = DateTime.Now.AddDays(7), Domain = "/" } });
IContentNegotiator negotiator = Configuration.Services.GetContentNegotiator();
ContentNegotiationResult result = negotiator.Negotiate(typeof(LoggedInModel), Request, Configuration.Formatters);
response.Content = new ObjectContent<LoggedInModel>(new LoggedInModel { Email = model.Email }, result.Formatter);
return response;
그것은 거기에 아무것도, 정말, 다시, 나는 쿠키 헤더를 볼 수 있습니다
이 서버 코드 (이 WebAPI입니다)입니다. 다음은 응답의 쿠키 헤더입니다.
Set-Cookie : auth = some-value-here; 만료 = Mon, 25 Mar 2013 20:39:43 GMT; 도메인 =/
IIS에서 실행하려고 했으므로 localhost-something이 도움이되지 않습니다.
CORS가 아닌 동일한 서버에서 "/ api/blah"유형의 주소로 아약스를 호출합니다.
어떤 아이디어가 없습니까?
답을 자세히 설명해주십시오. 이것은 미래에이 질문에 비틀 거린 사람들을 도울만큼 충분하지 않을 수도 있습니다. –