问题
I have a web app that is used mainly for monitoring a system. It uses signalr to "server-push" updates from the server to refresh the display. The page also has some buttons which also uses the same signalr connection to send data to the server.
The problem is signalr uses a separate connection so the session expires after the session timeout even when it is regularly sending and receiving data from the server.
Is this the "correct" way to use signalr? Or should I just use signalr to inform the client of updates and have the client do an ajax post to retrieve the data?
What about the session timeout issue? Do I have to create a client-side timer to regularly make a "keep-alive" ajax post?
回答1:
You should be able to workaround the session timeout issue by sending a request every 5 minutes (anything lower than your cookie timeout), to your webserver (just any random page). We're actually going to implement something to improve this in of SignalR 2.0.
来源:https://stackoverflow.com/questions/17800826/session-timeout-when-using-signalr