简体   繁体   中英

How do I progressively render a header before content in ASP.NET master pages?

I have a large slow ASP.net site that uses master pages.

I've identified that the user will have a better experience if they can see the header and navigation while the rest of the page is being generated/processed/loaded from the database.

I've done some simple tests and I can do Response.Write() followed by Response.Flush() in page_load(), and IIs will use chunked encoding and send the output to the browser immediately while the rest of the page renders.

I want to do the same thing, but only send the master page header and navigation.

Any pointers on how to achieve this?

Using ASP.net 4 and IIs 7.5

If anyone can give some pointers on how to change the site to use AJAX without having to change every page and link, I'd appreciate it. Thanks!

If you flush the response stream at some point manually and do not manually set the content length it will enable chunked encoding.

This question seems related: How can I set Transfer-Encoding to chunked, explicitly or implicitly, in an ASP.NET response?

And this blog post talks about response flushing and chunked encoding: http://www.rahulsingla.com/blog/2010/06/asp-net-sets-the-transfer-encoding-as-chunked-on-premature-flushing-the-response

I suggest you use control caching. Asp.Net provides native caching of pages and controls. See these links to know more.

ASP.NET Caching: Techniques and Best Practices

http://msdn.microsoft.com/en-us/library/aa478965.aspx

ASP.NET Caching

http://msdn.microsoft.com/en-us/library/xsbfdd8c(v=VS.100).aspx

Control caching

As you have mentioned, it appears that you already use page-caching. Try using control-caching to further improve the caching. To use control caching, place PartialCachingAttribute over the control class. You can use the ControlCachePolicy of the control to set caching behavior:

control.GetCachePolicy()

I would suggest tracing the page, and try to figure out why exactly the page is rendering slow. The following might help...

http://www.dotnetscraps.com/dotnetscraps/post/How-to-troubleshoot-issues-with-Page-Rendering-in-ASPNET.aspx

And use DIVs in place of TABLEs!

Regarding AJAX usage, AFAIK... there is no shortcut. You can use AJAX script manager in your master page, and use the script manager proxy to the pages where you want to ajaxify the page. Change your Form to introduce an Update panel and you should be good for most pages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM