Question

I have a c# ASP.NET program that takes over 1 minute for the page, b.aspx, to load when clicking on a chart in page a.aspx that opens b.aspx.

I thought it might be my queries in b.apsx, but it turns out they run really quick. Putting some logging into my code I see that from the time the page/class in b.aspx is instantiated to the time it gets to Page_init is 52 seconds by itself. It appears that a.aspx which takes 52 seconds to load is performing a PostBack and loading again before I can get to b.aspx.

I have set the following in my chart in a.aspx.

Chart.Series[series].LegendPostBackValue = "SomeValue";
Chart.Series[series].LegendUrl = url;

In Chart_Click() I set a session value so I can reference it in b.aspx.

HttpContext.Current.Session["value"] = e.PostBackValue;

In b.aspx I access the data using

String somevariable = HttpContext.Current.Session["value"].ToString();
Was it helpful?

Solution

The page took a long time to reach page_init because it had to reload the calling page due to postback before loading the new page. The reload was caused by LegendPostBackValue.

a.aspx, the page clicked on to get to b.aspx had a LegendPostBackValue set. This would cause a reload of a.aspx taking an additional 52 seconds. Removing

Chart.Series[series].LegendPostBackValue = "SomeValue";

and removing setting a session value in Chart_Click

HttpContext.Current.Session["value"] = e.PostBackValue;

and instead using

Chart.Series[series].LegendUrl = url + "?value="SomeValue";

and on page b.apsx use

String somevariable = HttpContext.Current.Request.QueryString["value"];

instead of

String somevariable = HttpContext.Current.Session["value"].ToString();

fixed the problem. Page a.aspx does not have to reload because there is no postback value and instead follows the url to b.aspx.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top