Saravanan
Saravanan

Reputation: 7854

Cookies are not set in the Response from Web API

Hi I am running into a strange issue, that is when I am working, all of a sudden the cookies are not set properly in the response from Web API.

I am using Web API 5.2 and it sets a cookie [OWIN] and the client application reads the cookie and then authenticates via the Cookie Authentication Middleware.

It was working fine, but the cookies were not set suddenly. When I restart the PC, it all started to work fine.

I have had this issue when the datetime was changed in the machine, however it happens all of a sudden in normal cases also.

Anybody have already faced this kind of issue, please share your findings.

Note: We are using the WebAPI as our Authorization Server and the Client application is an ASP.Net MVC 5.2 application.

We are using Redis cache as the session state manager.

Upvotes: 0

Views: 2612

Answers (1)

Saravanan
Saravanan

Reputation: 7854

Since, we were using Redis Session-State, we were not getting the cookies set properly.

However, when I googled, i found that the set-cookie header was being overwritten and hence the cookies set earlier were lost. This was due to a situation where the ResponseCookies collection were serialized into the headers.

However, the solution was suggested to initialize the session to begin before the authentication happens. This was tried and is working fine.

Hope this helps someone who may encounter it in future.

ASP.NET_SessionId + OWIN Cookies do not send to browser

Upvotes: 1

Related Questions