While working on a web application using ASP.NET Web API and SignalR, I encountered an issue that is proving to be quite challenging despite my understanding of HTTP.
Currently, I have successfully set a cookie on all AJAX requests to the API, and subsequent requests send the cookie seamlessly. However, I am now facing a hurdle as I want this cookie to also be included in the SignalR requests that establish a connection. Chrome, however, is not sending the cookie in these requests. The cookie is set as HTTPOnly, and all requests are being made locally to localhost:port
with the cookie's domain set as localhost
.
My SignalR connections are structured like this:
var connection = $.connection("/updates");
/* set handlers here */
connection.start(function () {
console.log("connection started!");
});
Despite the requests being on the same domain, Chrome appears to view them as CORS requests and is not sending the cookies. This behavior is puzzling, given that they should be on the same domain.