Owin cookie-Authentifizierung set-cookie nicht speichern im browser
Baue ich selbst-gehostete web-server auf diesem Stapel:
OWIN
Nancy
Web-Api-2 -
Und ich bin mit Microsoft.Owin.Sicherheit.Cookies von Katana für Formen-wie die Authentifizierung. Ich habe Set-Cookie-header in der Antwort, aber cookie nicht gespeichert wird und nicht im nächsten Anfrage. Was ist also das problem? Was mache ich falsch?
Owin startup:
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationMode = AuthenticationMode.Active,
AuthenticationType = "GM",
CookieHttpOnly = true,
CookieSecure = CookieSecureOption.SameAsRequest,
CookiePath = "/",
CookieName = CookieAuthenticationDefaults.CookiePrefix + "GM",
CookieDomain = "localhost",
});
- Controller-code:
var context = Request.GetOwinContext();
context.Authentication.SignIn(new AuthenticationProperties()
{
IsPersistent = true
},
new ClaimsIdentity(new[] {new Claim(ClaimsIdentity.DefaultNameClaimType, user.Login)}, "GM"));
context.Response.Headers.Add("Location", new []{ "/" });
return Request.CreateResponse(HttpStatusCode.Found);
Antwort-Header:
Cache-Control:no-cache
Content-Length:0
Date:Wed, 11 Sep 2013 11:11:23 GMT
Expires:-1
Location:/
Pragma:no-cache
Server:Microsoft-HTTPAPI/2.0
Set-Cookie:.AspNet.GM=AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAABui2rBibE0yPXB0-v3C06gAAAAACAAAAAAAQZgAAAAEAACAAAAC1mQV3jGo_WAhMQ-hzsmzgkdbdCclWIAX-msbE0_12zQAAAAAOgAAAAAIAACAAAABuQjBg3EJIka151hvBgtlPGfQ2O_cwNI2VVh86dchTDXAAAAD21O9DnNk4yLU9eddVfY3bT9P1CEudNeLvwohkSTAQBP2onuIQfgl9F99Je5waPddckh2llD2kjftSMQPhzgE9vKm-_wE42hXhc9FIgfxpD5AdaeGatwpEcwDfGJJdpQnObX1pbjEFIXLVJxGm5qMUQAAAAC8AiFTaXmzrfRy4-jR6zqMmSKddzddmiBLGClAckWOy6W2YWdf50N2zhIj_MwN8-zi-B0tlv87pzAt-6RDZYZs; domain=localhost; path=/; expires=Wed, 25-Sep-2013 11:11:24 GMT; HttpOnly
Ich habe das cookie senden, und vierten, aber meine nächsten Wünsche sind nicht validiert, konnten Sie erreichen, dass?
InformationsquelleAutor | 2013-09-11
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich das Problem gelöst. Es war, weil 'domain=localhost'. Es scheint zu 'localhost' ist kein Gültiger Wert für die domain-parameter.
InformationsquelleAutor Кеша Шушпанов
Könnten Sie encounting ein ähnliches Problem: Safari nicht gesetzt, Cookie, aber IE /FF funktioniert
Versuchen Sie, die Einstellung der HttpStatusCode zu HttpStatusCode.Ok
Einigen Browsern nur cookies von einer bestimmten response-code (wie 200, 302).
Haben, überprüfen Sie die expires-Wert auf den Keks. Es ist nicht ablaufende sofort, richtig?
Wie Sie sehen können, es erlischt 25 ' th September. Ich habe tryed set Ablauf der Zeitspanne von 30 Tagen, aber zu keinem Ergebnis. Ah, ich bin auch mit nicht-Standard-port 8080 verwendet wird, kann es Störungen verursachen?
Ich habe das Problem gelöst. Es war, weil 'domain=localhost'. Es scheint zu 'localhost' ist kein Gültiger Wert für die domain-parameter.
InformationsquelleAutor Jeremy Bell