ASP.NET_SessionId + OWIN Cookies do not send to browser

后端 未结 9 1412
误落风尘
误落风尘 2020-11-22 14:00

I have a strange problem with using Owin cookie authentication.

When I start my IIS server authentication works perfectly fine on IE/Firefox and Chrome.

I st

9条回答
  •  长情又很酷
    2020-11-22 14:35

    I had the same symptom of the Set-Cookie header not being sent but none of these answers helped me. Everything worked on my local machine but when deployed to production the set-cookie headers would never get set.

    It turns out it was a combination of using a custom CookieAuthenticationMiddleware with WebApi along with WebApi compression support

    Luckily I was using ELMAH in my project which let me to this exception being logged:

    System.Web.HttpException Server cannot append header after HTTP headers have been sent.

    Which led me to this GitHub Issue

    Basically, if you have an odd setup like mine you will want to disable compression for your WebApi controllers/methods that set cookies, or try the OwinServerCompressionHandler.

提交回复
热议问题