0

We are storing session data in the database, ideally each developer wants a session database on their own pcs, or possibly 1 developer might use inproc, another a mssql connection, another Oracle (if we get it working)

Is this possible? Can you access the session key in code and change it in the application startup? Or is there a file which could be merged with the web.config file that wouldn't get checked in?

Or option C which is easier but which I haven't thought of :-)

thanks

(Edit) Just found this which goes into this in some detail developer specific app.config/web.config files in Visual Studio

(Answer). This came from a mix of Andrew Barber in the comments and the above

(1) In the web.config have this

<sessionState configSource="SystemWeb.config" />

(2) Make a file called SystemWebDefault.config which holds something like this:

<sessionState mode="SQLServer" allowCustomSqlDatabase="true" etc

(3) Each developer has to copy the default into a file called SystemWeb.config, changing it to suit themselves. This file should be explicitly ignored in subversion or whatever source control system you use.

(4) The build box needs a copy step

Community
  • 1
  • 1
tony
  • 2,178
  • 2
  • 23
  • 40
  • use windows authentication or have a dev config file - transform that for production. i don't think devs would need sql session data. – Daniel A. White Aug 18 '14 at 17:15
  • It's to make sure nothing gets added which won't go into the database, i.e. non serializable or similar – tony Aug 18 '14 at 17:20
  • Easiest thing to do is local config files, and local SQL Dev instances for those who want to use database session storage. – Andrew Barber Aug 18 '14 at 17:30
  • local config files was the answer, add that as an answer and I'll accept it – tony Aug 19 '14 at 06:28

1 Answers1

0

Something that might do what you want is NConfig (NuGet link). I've used it on projects to let multiple developers in our team have different connection strings for their local DB copies. It lets you define a machine specific config file to replace your default config values. For example you can define a {MachineName}.Custom.config that might look like this:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="main" connectionString="data source=(local)\SQLExpress;uid=username;pwd=password;initial catalog=mydb" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

I've never tried it with the session settings, but I can't find anything that says it won't work.

Becuzz
  • 6,846
  • 26
  • 39