ASP.NET Session Configuration

Topics: Developer Forum, User Forum
Oct 21, 2009 at 6:38 AM

 

Hi,

Many thanks for the hard work, really was pretty easy to configure and work with..

I have a question, are there any examples of using the ASP.NET session handler that's in the SharedCache, atleast what needs to be added to the web.config in order to have it working ?

Any help is much appreciated.

Thanks..

Nov 3, 2009 at 12:58 PM

Bump... if anybody got any info on setting this up (howto- asp.net sessions HTTP or Inproc) please post.

Feb 22, 2010 at 3:23 PM

Sorry all.  I never signed up for alerts and was oblivious to these questions being raised.  

I wrote the Session Provider last year when I was benchmarking 6 or 7 other session store provider options.  I wanted one open source solution so I contributed the code to SharedCache.  In full disclosure, I don't use this provider in any production environments and I advise everyone who is interested to fully stress test their applications.  And if you could post those results to this forum, that would be great!  

As of the writing of this forum post, there have been no releases of SharedCache that contain this new session provider code.  You will need to download the trunk of the shared cache project, compile your own dll, and import this dll into your web projects.  To use SharedCache as the session provider for your ASP.NET application, you simply need to add a few lines to the web.config.  Not only do you need to add the SharedCache configuration (just as you would need to add for any application), but also instructions for how to use shared cache as the session state provider.  Here is the code for a full (and simple) web.config:

 

<?xml version="1.0"?>
<configuration>
	<configSections>
		<section name="indexusNetSharedCache" type="SharedCache.WinServiceCommon.Configuration.Client.IndexusProviderSection, SharedCache.WinServiceCommon"/>
	</configSections>

	<indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
		<clientSetting
				SharedCacheVersionNumber="3.0.5.2"
				LoggingEnable="1"
				CompressionEnabled="0"
				CompressionMinSize="1024000"
				HashingAlgorithm="Hashing"
				SocketPoolMinAvailableSize="5"
				SocketPoolValidationInterval="00:02:00"
				SocketPoolTimeout="00:02:00"
				EncryptionProviderHashSalt="supersecrethash"
				/>
		<servers>
			<add key="localhost" ipaddress="127.0.0.1" port="48888"/>
		</servers>
		<providers>
			<add name="IndexusSharedCacheProvider" type="SharedCache.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, SharedCache.WinServiceCommon" />
		</providers>
	</indexusNetSharedCache>
	
	<connectionStrings/>

	<system.web>
		<authentication mode="Windows"/>

		<sessionState
			cookieless="false"
			timeout="480"
			mode="Custom"
			customProvider="SharedCache">
			<providers>
				<add name="SharedCache" type="SharedCache.WinServiceCommon.Provider.Session.IndexusSharedCacheStoreProvider, SharedCache.WinServiceCommon" />
			</providers>
		</sessionState>

		<compilation debug="true"/>
	</system.web>

	<startup>
		<supportedRuntime version="v2.0.50727"/>
	</startup>
</configuration>