This has been deprecated! Please see this post
After reading various old
blog posts about moving the ViewState to the end of the page using an HttpModule, I decided to create an HttpModule to store the ViewState in memcached, eliminating the need to send the data back and forth to the client and stopping prying eyes from seeing the ViewState.
Halfway through writing the HttpModule, I discovered that
Philip Rieck had already
written a pluggable ViewState manipulation HttpModule, so I made a memcached plugin for it using the
BeITMemcached client.
To get this up and running on your site, download the latest source from http://code.google.com/p/memcachedviewstatehttpmodule/ and follow these steps
1. Copy all the code from the Release folder into your web sites bin directory
2. Merge the xml below into your web.config and edit the memcached server addresses
<configuration>
<configSections>
<section name="beitmemcached" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<appSettings>
<add key="viewRestateStore" value="Assembly"/>
<add key="viewRestateStoreType" value="MemcachedViewStateStore.MemcachedViewStateStore,MemcachedViewStateStore"/>
</appSettings>
<beitmemcached>
<add key="ViewStateCache" value="127.0.0.1" />
</beitmemcached>
<system.web>
<httpModules>
<add name="viewrestate" type="NFission.Web.ViewRestateModule,NFission.Web.ViewRestate"/>
</httpModules>
</system.web>
</configuration>
3. That should be it. A couple of words of warning. I haven't used this in production yet, but will hopefully do so sometime in the next week. Also, I haven't distibuted the source for Philip Riecks HttpModule as I don't know the licence for it. I had to make a couple of minor changes to get it to work correctly
- I commented out the GZip stuff as I'm not using it
- changed line 72 of VsInFilter from Buffer.BlockCopy( this.dataBuffer, (int)position, buffer, offset, count); to Buffer.BlockCopy( this.dataBuffer, (int)position, buffer, offset, realCount);).
- changed line 16 of VsFilter from private const string ViewstateKey = "name=\"__VIEWSTATE\ value=\"";" to private const string ViewstateKey = "id=\"__VIEWSTATE\" value=\"";
I'm trying to get in touch with Philip to clear up the licence.
5 comments: