1

I encountered a missing Session problem. After days of investigation, I found out the Session is missing when it tries to call AJAX post trigger by SignalR from localhost.

I have a local Windows service that is installed on the same VM where my website (ASP.NET MVC 4 hosted in IIS) is hosted. It will do some tasks and when it is completed, it sends a notification via https://localhost/api/notify. This in turn uses a SignalR to broadcast a message.

When the client browser receives this message, it will do an AJAX call back to /CPanel/OptiTasks/RefreshData (the client will launch the page via an external URL - for example: https://example.com). However, when I tried to retrieve the Session variable, it disappeared.

I have tried to include withCredentials set to true, but the Session variable still disappeared.

In summary, here is the sequence:

  1. Client login to the website via external URL (eg. https://example.com)
  2. After login the client goes to page https://example.com/cpanel/optitasks
  3. On the OptiTasks page, it uses SignalR to listen to the update notification
  4. Windows Service --- Send Notification Via --> https://localhost/api/notify
  5. SignalR will broadcast a notification request which will received by the OptiTask page
  6. OptiTask page will do AJAX post (withCredentials = true) to /cpanel/optitasks/refreshdata
  7. In RefreshDataController, the Session variable is NULL (eg. Session["MySessionVariable"] is NULL)

I have searched online including using ChatGPT, but I am still unable to figure out how to fix this problem.

Please help.

2
  • Hi All, I solved the problem. I am using SessionState mode of StateServer. The problem was on the Windows Service, it used ServerManager to make various changes to server configuration (eg. update SSL cert) which caused IIS to recycle the application pool Commented Nov 26, 2023 at 3:37
  • You can add your own answer rather than a comment Commented Jun 4 at 11:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.