Here is a great way to help DNN 4.x performance for pages that have many modules, modules with many ViewState-hungry controls, and for sites with dial-up users.
I have been building a pair of modules for a company I'm consulting with. One of their requirements was to replace their old site with a DNN site, and to put everything from their two applications onto only two DNN pages. Their old app required clicking from page to page to page to do even the simplest tasks.
So I used DNN 4.0.x (ASP.NET 2.0), and used the Multiview control in my two modules. Trouble is, these modules have a couple hundred controls on each page (text boxes, check boxes, grid views, dropdowns), so the ViewState got HUGE. So huge that even on a local Intranet the response time was horrible, due to transmission load and browser rendering time. Yes, I went through the usual steps of disabling ViewState on every control possible, without having to write major chunks of code to compensate.
I did some digging, and found that ASP.NET 2.0 has the ability to save the ViewState server-side, already built in. So I followed some examples I found and put together a solution. This solution reduces ViewState in the browser to bare minimum, no more than 3 short lines of text when you look at it from "View source." The result was a major improvement in performance. (Less than 1 second to load a page, whereas before it was over 10 seconds.)
The beauty of this, too, is that it requires NO alteration of DNN 4.x Core code, and nothing special in the modules.
You can download the code from my web site at--
http://www.newcovenant.com/Portals/0/PageStateAdapter.zip
The zip file contains both source code and compiled code. It is only 5 kb in size.
To run this on your DNN 4.x site:
Before installing, connect to a page on your site. Open "View source" on the page, scroll down to the bottom, and look at how big the ViewState hidden field value is.
- Unzip the file.
- Open the "Install\bin" folder.
- Copy DotNetNuke.PageStateAdapter.dll to your site's bin folder.
- In the root of your site, create a folder named App_Browsers. (This is one of those ASP.NET "special" folders.)
- Open the "Install\App_Browsers" folder from the unzipped zip file.
- Copy the PageStateAdapter.browser file into the new App_Browsers folder of your site.
- Open your web.config file in an editor.
- In the <appSettings>...</appSettings> block, add this optional* key:
<add key="ServerSideViewState" value="true" />
- Save web.config back to your site.
That's it. Now connect a browser to the same page of your site. (Of course, since you altered web.config it will take a bit longer to open the first time.) Check "View source" on the page, and scroll down to the ViewState hidden field. You will see that it is significanly smaller.
You can test the installation by simply changing the value of the new web.config key from "true" to "false" and back again. Check the "View source" each time to see how the feature turns on and off.
*If the "ServerSideViewState" key does not exist in web.config, but you installed the .dll and the .browser files, the site will behave as normal. No error, and ViewState will be in the web page. If the key is not present in web.config, it's the same as being set to "false." The values "0" and "1" should work, too, since the code uses--
Convert.ToBoolean(appSettings("ServerSideViewState"))
David Haggard
NewCovenant Consulting