0

我有一个关于在 MVC3 Web 应用程序中使用 LightSpeed 的问题。我正在创建一个 REST Api 项目,我想在其中使用 LightSpeed,但官方配置指南非常模糊。官方文档说需要将以下几行添加到文件 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>

我尝试在根目录中的 web.config 中添加以下行:

<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>

这会在我启动 Web 应用程序时引发异常,告诉我在应用程序中不能多次指定 configSections。默认情况下,根 web.config 文件没有指定任何这些。

我不确定在哪里放置这个配置。

4

1 回答 1

0

好的,我找到了解决问题的方法。

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.

于 2012-04-08T18:20:36.650 回答