Answered by:
SQL Sever Session state issue with load balancing

Question
-
User1291893290 posted
Hi,
Problem :
In Application, the page gets redirect to 3rd party page, when it retrun to the application, some times session is lost due to it wrong result is getting.
Not able to understand the resaon of session lost in sql server.
I had done below configuration.
Configurations:
Websever 1 and webserver2 both deplaoyed Asp.net MVC application with sql server session state mode enabled.
I have added machine key as well in both the server's web.config
Application is hosted under Defaultwebsite in IIS
both application having same ApplicationID and path.
Any help would be appreciated.
Tuesday, February 27, 2018 11:10 AM
Answers
-
User1291893290 posted
If we are having any object in Sql server State Session,it should be serialized.
i:e
[Serializable]
public class customer{
public string UserName { get; set; }
public string FirstName { get; set; }
}
and then set it to session Variable
public enum SessionVariable
{
/// <summary>
/// The user
/// </summary>
User
}Session[SessionVariable.User.ToString()] = GetCustomerByEmails(user.Email, "");
It will work successfully with sql session.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 5, 2018 10:46 AM
All replies
-
User541108374 posted
Hi,
and as long as people remain on one of these servers all goes well? Is the session cookie expired?
Kris.
Tuesday, February 27, 2018 11:51 AM -
User1291893290 posted
Yes any one of single server it goes well.
no session cookie doesn't get expired.
Any help on it?
Thanks!
Wednesday, February 28, 2018 9:36 AM -
User-832373396 posted
Hi <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="5" data-gr-id="5">Dixsita</g>,
Here is just an idea, how about <g class="gr_ gr_82 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" id="82" data-gr-id="82">localstorage</g> as workaround
- What is HTML Web Storage?
With web storage, web applications can store data locally within the user's browser.
Before HTML5, application data had to be stored in cookies, included in every server request. Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance.
Unlike cookies, the storage limit is far larger (at least 5MB) and the information is never transferred to the server.
Web storage is per origin (per domain and protocol). All pages, from one origin, can store and access the same data.
- Guide
https://www.w3schools.com/html/html5_webstorage.asp
With regards, Angelina Jolie
Thursday, March 1, 2018 3:01 AM -
User1291893290 posted
Here, we are redirecting application page to other domain(paymentgateway) and from payment gateway redirect back to Merchant site(our application)
when it receive back to merchant website, session is lost in case of sql server.
Is it happening because of domain redirection to and fro?
Any comments on session behavior.
Thursday, March 1, 2018 11:43 AM -
User1291893290 posted
If we are having any object in Sql server State Session,it should be serialized.
i:e
[Serializable]
public class customer{
public string UserName { get; set; }
public string FirstName { get; set; }
}
and then set it to session Variable
public enum SessionVariable
{
/// <summary>
/// The user
/// </summary>
User
}Session[SessionVariable.User.ToString()] = GetCustomerByEmails(user.Email, "");
It will work successfully with sql session.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 5, 2018 10:46 AM