I am confused with multiple calling of Application_BeginRequest on single click where portal settings are fetched from Database and set in the context as:
Context.Items.Add("PortalSettings", new PortalSettings(tabIndex, tabId));
I agree that Application_BeginRequest will be called with single web event, but i wonder it is getting called four times on every clcik. is there any other series of events being raised as a result of single click in the portal? Also DesktopPortalBanner is loaded twice on every single click leading to performance issues of the portal. Thanks in advance for any help ...
Application_Start is raised when the Application starts.
Application_BeginRequest is raised when any Web Forms page or XML Web service in your application is requested. This event allows you to initialize resources that will be used for each request to the application. A corresponding event, Application_EndRequest, provides you with an opportunity to close or otherwise dispose of resources used for the request.
Session events are similar to application events (there is a Session_Start and a Session_End event), but are raised with each unique session within the application. A session begins when a user requests a page for the first time from your application and ends either when your application explicitly closes the session or when the session times out.
protected void Application_BeginRequest(Object sender, EventArgs e) {
// NOTICE THE INITIALIZATION BELOW :
// THIS IS HOW THE tabIndex and tabId - INITITALIZED
// SINCE THE FOLLOWING 2 ifs WOULD BE FALSE.
int tabIndex = 0;
int tabId = 1;
// Get TabIndex from querystring
if (Request.Params["tabindex"] != null) {
tabIndex = Int32.Parse(Request.Params["tabindex"]);
}
// Get TabID from querystring
if (Request.Params["tabid"] != null) {
tabId = Int32.Parse(Request.Params["tabid"]);
}
// Build and add the PortalSettings object to the current Context
Context.Items.Add("PortalSettings", new PortalSettings(tabIndex, tabId));