I have an ASP.NET Webforms master page which is taking 3.5 minutes to render, and I can't figure out why.
I added logging, and it goes through Load and PreRender super fast, but after that, takes 3.5 minutes to get to Unload.
The page being rendered is pretty small, about 80k, and the viewstate is about 10k (guessing).
Figured it out. In my case, Umbraco was responsible for generating the 'Page' as all I had was a MasterPage containing controls. One of these controls had a datasource which was making web requests for each row it got back from the database. These requests were failing silently and timing out.
Related
Apologies if this is vague or too general, I know we are supposed to ask specific programming questions, but this is to try and understand how postbacks work in ASP.NET when something is rendered on page initially, and not touched on postback, yet still appears on screen after these postbacks.
Detail: I have an ASPX page - on initial page load it sets up all the labels and controls and a repeater with thumbnails in it.
I can follow the code through as it sets up all components, which will then be rendered.
On postback, if a value has been changes (status for example), the page makes updates to database, and then re initializes the screen (calls the init method with postback set to false), setting up everything again (I think the aim was to set up certain controls like radio buttons for the status), including the image repeater again (which I think is a waste of time).
I have tested skipping the code that sets up the image repeater etc. on a status update (postback), and the image repeater displays fine in the browser - however I am not sure why - ASP.NET is stateless, so on a postback, if the page does not render all the components on the page everytime how can they persist between postbacks?
I know there is a reason out there, just can't frame my question well enough in google to find it. Does the server send back and update which the browser merges with the existing displayed page? Leaving all unchanges components as is?
The reason I need to know this, is I have a screen with a lot of images on it, and I do not want to be setting them every time unless I have to.
This link - provided by Steve (thank you very much) - was what I was looking for goes into depth on ViewState - vaguely remember reading about that when I first stated doing .NET - have completely forgotten about it, but this explains it perfectly!
Understanding ASP.NET ViewState
https://msdn.microsoft.com/en-us/library/ms972976.aspx
I have a page which uses WebParts to display differents sections that the users can configurate, so in this page can be lots of them, each of them calling to our API to retrieve DB data.
Right now, these sections are loading synchronously, and the page may need too much time to load, so I've wrapped each section in an UpdatePanel and tried to load them asynchronously. I use an asp:Timer to do so. Now, the page renders and then the UpdatePanels start to load when the timer ticks, but the problem is that these UpdatePanels load synchronously (one after the other). So, if the first UpdatePanel needs 10 seconds to load, the second one will start to load just after.
What can I do to load them all at once asynchronously?
Thanks in advance
asp.net webforms is not designed to work asynchronously, so as far as i know you cannot tweaks the updatepanels to do that.
I suppose you could somehow overload the updatepanel scripts, but it would really add too much complexity.
The easiest thing you could do is to not load all the webparts in the same page.
I have a scraper that scrapes data from three kinds of websites.
One of those websites (Facebook) have multiple page formats that needs to be scraped.
While two websites work fine, one particular Facebook page layout refuses to work or work very strangely. (for other Facebook page layouts I haven't noticed this behavior)
I am reading each link from a file and load into webbrowser control, I wait until each page fully loads (using AutoResetEvent) and then after it loads, I send pages html to other class from the webbrowser_Document_Completed event to do the scraping.
The problem here is that sometimes page is not fully loaded and sometimes it fully loads.
In both cases webcontrol_Document_Completed is fired.
When the page fully loads, it works just fine.
I debugged and indeed, page is not fully loaded and data is missing.
It can pass 4-5 times in a row to fully load the page and then suddenly stops. (random pattern)
I don't know anymore where to look for the culprit.
I thought that my code is not ok so I created new test project that just loads that page and same problem occurs.
So maybe the page is the problem because I also saw that when it doesn't work, needed data is commented.
Maybe some scrape protection...
Page in question is: https://www.facebook.com/pages/Childrens-Dental-Care/76095547112?v=info&viewas=0 and needs to scrape right side of the page where is Joined Facebook, Hours and Parking.
It's //td[#class='data'] element that I need.
If you have any idea that might point to solving this issue...
Thank you!
Or a way to detect it is finsihed rendering?
Actually almost exactly this question
Gridview, is there an event, how would I determine that it has finished being rendered?
but he does not state exactly how he detected that everything had been drawn/resized.
EDIT: (Adding my comment from below to specify what i am trying to do)
I am trying to create a work around for static header for a gridview by basically dynamically adding another gridview above the one that actually has the data in it. I resorted to this after trying about 12 different suggestions/solutions with no real luck. What i have works pretty well except that the new header is rendered before the one with the data in it completes its re-sizing, I realize what i am trying might not even work since it might require another postback to re-render the new one after i find the sizes of the column headers but thought i might get around that with an update panel.
I realize this might not be the most elegant solution but honestly have yet to find any solutions to this problem that come even close to elegant or have even worked correctly with current browsers.
It renders at the client so the server doesn't know what is happening there.
You are probably looking for the DataBound event.
Otherwise, at the client, you can determine when the page has finished loading (the jquery ready function) and then call back to the server. But I can't imagine anything useful you could do. If you send more data to the client and it renders again, you could have an infinite loop.
Everything in an ASP.Net webpage is rendered at the same consecutively at the same stage of the lifecycle (see http://msdn.microsoft.com/en-us/library/ms178472.aspx), so the Gridview will be rendered between Gridview_PreRenderComplete and Gridview_Unload.
You page PreRender will fire, then the control PreRender, then the page will call the Gridview Render method (there is no event for this) then the control Unload will fire and then the page Unload will fire.
Other posters to this question are referring to the client side rendering whereas I am referring to the server side rendering process. Which is it that you are actually after and why please?
For a tournament application, i have to output group standings and a knockout schedule. They have to alternate on one big LED TV. I managed to do that using an IFrame that spanned 100% of the page and using javascript to set the iframe source to another aspx page every 10 seconds.
This works but i creates an enormous memory leak. each time a page is loaded in the iframe, the Internet Explorer process grows with about 6mb. this results in a IE process of 1,5Gb and a crash of the window after about 1 hour.
Is there a better way to create something similar? do the cycling all in codebehind?
Thanx,
Cypress
Why the need for the iframe? You could just have the page reload every 10secs with an onload script.
A more clever approach, might be to use AJAX to download only the data you need to display & update the page with that. You could then take a stage further & use something like SignalR to only update the screen when the data changes.