मैं एक सत्र में उपयोगकर्ता आईडी और उपयोगकर्ता भूमिका को स्टोर करने के लिए एक कक्षा का निर्माण कर रहा हूं। मुझे यकीन नहीं है कि इस कक्षा में एक ही समय में साइट पर एकाधिक उपयोगकर्ता कब होंगे। क्या किसी को इसके साथ कोई समस्या दिखाई देती है?स्टेटिक सत्र कक्षा और एकाधिक उपयोगकर्ता
public static class SessionHandler
{
//*** Session String Values ***********************
private static string _userID = "UserID";
private static string _userRole = "UserRole";
//*** Sets and Gets **********************************************************
public static string UserID
{
get
{
if (HttpContext.Current.Session[SessionHandler._userID] == null)
{ return string.Empty; }
else
{ return HttpContext.Current.Session[SessionHandler._userID].ToString(); }
}
set
{ HttpContext.Current.Session[SessionHandler._userID] = value; }
}
public static string UserRole
{
get
{
if (HttpContext.Current.Session[SessionHandler._userRole] == null)
{ return string.Empty; }
else
{ return HttpContext.Current.Session[SessionHandler._userRole].ToString(); }
}
set
{ HttpContext.Current.Session[SessionHandler._userRole] = value; }
}
}
अस्थिर और स्थिर 'ग्लोबल' हेल्पर्स का उपयोग करने जैसे बुरे प्रथाओं को प्रोत्साहित करता है। यह एक तकनीकी मुद्दा नहीं है, दीर्घकालिक प्रभावों के साथ एक मानसिकता समस्या – MikeSW