c# - Need help identifying a subtle bug.. in IIS? The Session? Elsewhere..? -
I have a very small bug that I'm having trouble figuring out.
Background: We have 2 sites running on the same site on the same web server
- Site A - www.SiteA.com Is used
- Site B - Accessed by www.SiteB.com
When the first request is made, the site ID is identified on the basis of the host and The session is stored as follows:
Secure void Application_BeginRequest (Object Sender, EventArgs e) {string host = Request.Url.Host; Int siteId = New Sitemanager () GetSiteByUrl (host) .SiteId; If (session user.Instruction (). SiteID! = Site ID) {session user. Instruction () SiteId = siteId; }}
This ID has been determined to withdraw any data and to determine which style to present:
// This happens during the initial stage _site configuration = _siteManager.GetSiteById (session user.install (. SiteId); // then later: Private Zero SetpageTheme () {string theme = null; Switch (_siteconfiguration.SiteId) {case ConfigurationHelper.SITE.A: Theme = "Siteheme"; break; Case Configuration Heller.Site.B: Theme = "SiteBTheme"; break; } Page.Theme = theme; } problem: is facing the problem, if you both of the sites about At the exact same time, that is, in milliseconds, sometimes the SiteA will load from the topic of SiteB and vice versa. It is not often but it has come into the customer's attention, so now it is a problem. Something is happening somewhat within a few milliseconds, and I do not know how to Question: The difference between site A loading and sitb loading Does anyone have any ideas that can be wrong here? Something is confusing somewhere. Is it getting IIS requests? Is this a session collecting site that should be returned to the site id?
If more information is required, then I will provide it.
Update: For reference, this definition is Session User
(Basically, obtaining SiteID values from the session Make a stable example of an object):
public class sessionUser {personal static session user _instance; Public Int Site ID {Received; Set; } /// & lt; Summary & gt; ////// & lt; / Summary & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; Public static session user example () {if (null == _instance) {_instance = new sessionUser (); If (empty! = HttpContext.Current.Session) {if (null == HttpContext.Current.Session ["user"]) {If (HttpContext.Current.Request.QueryString ["sid"]! = Null) {int nSiteId = Int.Parse (HttpContext.Current.Request.QueryString ["sid"]); _instance.SiteId = nSiteId; HttpContext.Current.Session ["user"] = _instance; }} And {_instance = (session user) HTTP Contex. Running Session ["user"]; }}} Return _instance; }}
Without looking like a 'session user' class, I can only guess I am
I think session_server.Instance () returns a 'static' example (or instead of a member).
Now, it will be shared throughout the application, so it is understood that it can not be shared between 2 sites.
I recommend that you set HttpContext
to BeginRequest
.
Then the code will look like the following:
class session user {public static session user example () {var ctx = HttpContext.Current; Var su = ctx ["sessionUser"] as a session; If (su == null) {ctx ["sessionUser"] = su = new session user (); } Return; }}
Comments
Post a Comment