asp.net-mvc-3configurationlightspeed

Configuring Lightspeed for use in MVC3 Web project


I have a question regarding using LightSpeed in a MVC3 Web application. I am creating a REST Api project where I want to use LightSpeed, but the official configuration guidelines are quite vague. The official documentation says that the following lines need to be added to the file web.config:

<configSections>
   <section name="lightSpeedContexts" 
              type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
</configSections>

<lightSpeedContexts>
  <add name="Test" />
</lightSpeedContexts>

<lightSpeedContexts>
  <add name="Test" dataProvider="SQLite3" />
</lightSpeedContexts>

I tried adding following lines to the web.config in the root:

<configSections>
    <section name="lightSpeedContexts"
              type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
  </configSections>

  <lightSpeedContexts>
    <add name="Default" connectionStringName="Prod" dataProvider="MySQL5" />
  </lightSpeedContexts>

  <connectionStrings>
    <add name="Prod" connectionString="server=localhost;User Id=production;password=xxx;Persist Security Info=True;database=CBS"/>
  </connectionStrings>

This throws an exception when I start the Web application which tells me that configSections may not be specified more than once in the application. The root web.config file did not have any of these specified per default.

I am not sure where to put this configuration.


Solution

  • OK, I found out how to solve the problem.

    I moved out the configSections that were in the two sub web.config files (in each Views folder) and put the contents in the main web.config file, then I added the lightSpeedContexts and connectionStrings in the main web.config file.