Click here to Skip to main content
15,887,335 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Urgent help how creating forums with ASP.NET using C# Pin
ZurdoDev11-Mar-14 9:52
professionalZurdoDev11-Mar-14 9:52 
QuestionUsing CrystalReport Implement Print Pin
Mr.Roking8-Mar-14 23:13
Mr.Roking8-Mar-14 23:13 
QuestionWhy it is so hard to play with html in visual studio Pin
ankur11638-Mar-14 18:42
ankur11638-Mar-14 18:42 
AnswerRe: Why it is so hard to play with html in visual studio Pin
ankur11638-Mar-14 20:01
ankur11638-Mar-14 20:01 
SuggestionRe: Why it is so hard to play with html in visual studio Pin
Richard MacCutchan8-Mar-14 22:28
mveRichard MacCutchan8-Mar-14 22:28 
AnswerRe: Why it is so hard to play with html in visual studio Pin
Kornfeld Eliyahu Peter8-Mar-14 23:32
professionalKornfeld Eliyahu Peter8-Mar-14 23:32 
AnswerRe: Why it is so hard to play with html in visual studio Pin
jkirkerx10-Mar-14 13:55
professionaljkirkerx10-Mar-14 13:55 
Questionasp.net site taking all the CPU after a while Pin
Amaranth137-Mar-14 8:02
Amaranth137-Mar-14 8:02 
I have a big issue with the asp.net site I did. It's hosted on a server station, with IIS 7, and many clients (around 10) are accessing it. Around twice a week, the site is unacessible. When checking on the server, the CPU is at 100%. Resetting he application pool solves it.

The page has a auto-refresh function to update the products status (with color depending on the status). It fetches informations from other internal sites and Perforce. The refresh is done by a timer and set to 30 seconds.

<pre lang="HTML"><pre><asp:Timer ID="tmrTimer" OnTick="tmrTimer_Tick" Interval="300000" runat="server"></asp:Timer>


When the client select a product, I fill the page with the corresponding information. There is a table with the option runat="server" that I clear and fill with lines containing the information.

I place logs to check what was taking so long, but the total init time of the page is always under 1 second (there is information caching), even if the user has to wait more time than that to see the information.

At first, I thought the refresh was taking too long and that it was launching a new refresh before finishing the first one, so I increased the refresh time to 30 seconds, but it does not seem to be the case (unless the user clicks on another product before the product information finished displaying.

Here is my page initialization logic. It might not be the best way (since I don't have much experience with web programming), but it works. I only need to fix the CPU usage issue that forces us to reboot the server once in a while.

I think it might be caused by some threads working that were not terminated for some reason. I have to make a series of tests next week, but wanted to know in which direction to look or if someone had an idea.

C#
protected void Page_Load(object sender, EventArgs e)
 {
     //Menus are updated here instead of in the page_init because the items.clear
     //did not seem to work when called from page_init
     if (IsPostBack)
     {
         return;
     }
     var d = DateTime.Now;
     UpdateMenus();
     Log.Info("Update menus : " + DateTime.Now.Subtract(d).Milliseconds + " ms");
 }

 protected void Page_Init(object sender, EventArgs e)
 {
     //Variables for logging purposes
     var source = "";
     var t = DateTime.Now;
     var d = DateTime.Now;

     //Fetch the product Id
     SessionSettings.SelectedProductId = Request.QueryString["ProductId"];

     if (!IsPostBack)
     {
         CreateMenusDictionnary();
         SessionSettings.TurnAllDisplayOff();
         Session[CURRENT_BRANCH_KEY] = null;
         Session[CURRENT_SOFTWARE_KEY] = null;
         DisplaySelectedProductInfo();
         source = "(startup)";
         if (!string.IsNullOrEmpty(SessionSettings.SelectedProductId))
         {
             source = "(" + SessionSettings.SelectedProductId+ ")";
         }
     }

     if (Session["updateProducts"] != null && (bool)Session["updateProducts"])
     {
         d = DateTime.Now;
         UpdateProducts();
         Log.Info("Update products status : " + DateTime.Now.Subtract(d).Milliseconds + " ms");
     }

     var ctrl = WebApplicationHelper.GetPostBackControl(this);

     //Prevents update by timer when refreshing something else
     if (!(ctrl is Timer))
     {
         tmrTimer.Enabled = false;
     }

     if(ctrl != null)
     {
         CreateMenusDictionnary();
         if (ctrl is Button)
         {
             var p = FindProduct(SessionSettings.SelectedProductId);

             if (Session[SessionSettings.TABLE_MANAGER_KEY] == null)
             {
                 Session[SessionSettings.TABLE_MANAGER_KEY] = new ProductsInfoTableManager(productInfoTable);
             }
             var manager = (ProductsInfoTableManager)Session[SessionSettings.TABLE_MANAGER_KEY];
             manager.SetProductsInfoTable(productInfoTable);
             source = "(Expand button)";
             switch (ctrl.ID)
             {
                 case "diffButton":
                     SessionSettings.ShowDifferences = !SessionSettings.ShowDifferences;
                     manager.RefreshDiffFixes(p);
                     break;
                 case "fixesButton":
                     SessionSettings.ShowFixes = !SessionSettings.ShowFixes;
                     manager.RefreshDiffFixes(p);
                     break;
                 case "manualTestsDisplayChangelistsButton":
                     source = "(manualTestsDisplayChange)";
                     SessionSettings.ShowManualTestsByType = ExcelTestsReader.AggregateType.Changelist;
                     SessionSettings.TurnOffTestsDisplay();
                     manager.RefreshManualTests(p);
                     break;
                 case "manualTestsDisplayTestNamesButton":
                     source = "(manualTestsDisplayChange)";
                     SessionSettings.ShowManualTestsByType = ExcelTestsReader.AggregateType.Test;
                     SessionSettings.TurnOffTestsDisplay();
                     manager.RefreshManualTests(p);
                     break;
                 default:
                     if (ctrl.ID.StartsWith("errors_"))
                     {
                         SessionSettings.ToggleShowErrors(ctrl.ID);
                         manager.RefreshWorkflowErrors(p);
                     }
                     else if (ctrl.ID.StartsWith("manualTestsExpand_"))
                     {
                         SessionSettings.ToggleShowManualTest(ctrl.ID);
                         manager.RefreshManualTests(p);
                     }
                     else
                     {
                         DisplaySelectedProductInfo();
                     }
                     break;
             }
         }

         if (ctrl is Timer)
         {
             source = "(timer)";
             d = DateTime.Now;
             UpdateProducts();
             Log.Info("Update products status (timer) :" + DateTime.Now.Subtract(d).Milliseconds + " ms");
             DisplaySelectedProductInfo();
         }
     }
     Log.Info("Total init time " + source + " : " + DateTime.Now.Subtract(t).Milliseconds + " ms");

     //Reactivates timer
     if (!tmrTimer.Enabled)
     {
         tmrTimer.Enabled = true;
     }
 }


 //Refreshes the informations periodically for real-time monitoring
 protected void tmrTimer_Tick(object sender, EventArgs e)
 {

 }

AnswerRe: asp.net site taking all the CPU after a while Pin
jkirkerx10-Mar-14 14:01
professionaljkirkerx10-Mar-14 14:01 
GeneralRe: asp.net site taking all the CPU after a while Pin
Amaranth1311-Mar-14 4:33
Amaranth1311-Mar-14 4:33 
GeneralRe: asp.net site taking all the CPU after a while Pin
jkirkerx11-Mar-14 7:10
professionaljkirkerx11-Mar-14 7:10 
QuestionSet label for gridview while export to excel Pin
vignesht507-Mar-14 7:52
vignesht507-Mar-14 7:52 
QuestionCustomize the WebApi2 Authentication and Authorization + Oauth Pin
Member 103245156-Mar-14 20:41
Member 103245156-Mar-14 20:41 
QuestionBlog Pin
dotnetpls6-Mar-14 7:53
dotnetpls6-Mar-14 7:53 
AnswerRe: Blog Pin
Richard Deeming6-Mar-14 8:08
mveRichard Deeming6-Mar-14 8:08 
GeneralRe: Blog Pin
dotnetpls6-Mar-14 8:59
dotnetpls6-Mar-14 8:59 
GeneralRe: Blog Pin
Richard Deeming6-Mar-14 9:46
mveRichard Deeming6-Mar-14 9:46 
Questiongateway Pin
punith Kumar Raj6-Mar-14 3:19
punith Kumar Raj6-Mar-14 3:19 
SuggestionRe: gateway Pin
Richard Deeming6-Mar-14 3:39
mveRichard Deeming6-Mar-14 3:39 
QuestionMVC4 Razor @model - what's equivalent in ASPX view engine? Pin
Swab.Jat6-Mar-14 0:06
Swab.Jat6-Mar-14 0:06 
AnswerRe: MVC4 Razor @model - what's equivalent in ASPX view engine? Pin
thatraja6-Mar-14 1:57
professionalthatraja6-Mar-14 1:57 
GeneralRe: MVC4 Razor @model - what's equivalent in ASPX view engine? Pin
Swab.Jat6-Mar-14 2:44
Swab.Jat6-Mar-14 2:44 
GeneralRe: MVC4 Razor @model - what's equivalent in ASPX view engine? Pin
thatraja6-Mar-14 3:29
professionalthatraja6-Mar-14 3:29 
GeneralRe: MVC4 Razor @model - what's equivalent in ASPX view engine? Pin
Swab.Jat6-Mar-14 3:36
Swab.Jat6-Mar-14 3:36 
Questionaccess data from another table Pin
Patel Vinay V5-Mar-14 23:54
Patel Vinay V5-Mar-14 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.