In order to setup ViewState-Server/Open-ViewSate, the web.config file, will need to nest the following code inside the above structure:
Web.config modifications explained:
The following is an explanation of what each section will do, and how to configure the attributes needed to optimize ViewState-Server/Open-ViewSate.
Section: <viewstate>
The viewstate section contains the defaultProvider attribute. This is where you indicate what caching method you intend to use.
your options are: XMLViewStateProvider | CacheViewStateProvider. When selecting either one, the configuration that applies is the one that you specify in the appropriate providers section.
Section: <providers>
The providers section, contains the configuration parameters of the two caching modes: XML, or Cache. Let's see how to configure each one in turn:
XMLViewStateProvider will save Viewstate to an XML file. On the server, there will be one file per user. It has the following parameters:
-
fileCacheMinutes - determines how long the xml file in which viewstate is saved, will be allowed to stay idle, before being deleted.
-
recordCacheMinutes - determines how long a record entry in the above file will be allowed to stay idle. The XML file, will contain multiple ViewStates, from the various pages a user is navigating through. This is useful in case a user decides to hit the back button, or there is a pop-up open. Setting this parameter to a few minutes, ensures that the back button will work for the minutes you decide, and that your file system does not get bloated.
-
virtualPath - determines where the XML file will be saved. If this directory does not exist, it will be created automatically by the module. Make sure that the directory you choose has r/w access for the ASPNET or Network Services user.
CacheViewStateProvider will save Viewstate to Cache. It has the following parameters:
- cacheMinutes - determines how long the cached viewstate will be allowed to stay idle, before being deleted. The priority with which the ViewState is saved is Normal, that means that if your server memory is running low, that memory space will be dumped, and you will loose your cache before expected. It is important to know the volume of your site, and the memory limits of the hosting provider. When recycled prematurely, the page will not fail, but post to itself, thus initiating a new caching cycle.
Section: <excluded>
The excluded section is used if you want to exclude some .aspx pages from implementing ViewState caching on the server. This may be necessary if a page performs file uploads, such as the File Manager in a DNN standard Installation. (if this section is not needed, just delete it).
To exclude a URL from having the viewstate cached, you would create an entry as such:
<add url="/path/page_to_exclude.aspx" parameter="parameter_is_optional=value" />
Note that you can
leave the parameter blank if not needed.
Open-ViewState Only: In the case of DNN Version 3.x, the pages that MUST be excluded are the "File Manager" pages for host(tabid=19) and admin(tabid="46"). (the default entries that you see do the exclusion already). This is so, because when uploading a file, Open-ViewState interferes with the uploading process. If you create subportals, the admin "File Manager" will have a different tabid that the default portal, and an appropriate entry must be added in the <excluded> tag.
Section: <noOverwrite>
Every time the same page is requested, old page ViewState is overwritten with the new one. In this manner, the cached ViewState replaces itself with the latest values, and the cache medium (either file or cache) does not grow disproportionately.
Under some circumstances however, you do want the same page to keep all versions of its ViewState. Configuring the noOverwrite section, will keep a separate ViewState instance of the designated page, for every request the user makes.
Note that this configuration will also grow your file/cache size on every single request. So, the advice is to keep the recordCacheMinutes (for the XML provider) or cacheMinutes (for the Cache provider) as low as possible when this section is configured. (if this section is not needed, just delete it).
To exclude a URL from having the viewstate overwritten on every single request, you would create an entry as such:
<add url="/path/page_to_exclude.aspx" parameter="parameter_is_optional=value" />
Note that you can leave the parameter blank if not needed.