为什么已部署的空 MVC4 项目有错误和对默认连接字符串的引用



我可以在Visual Studio 2012中创建一个空的MVC4项目。添加一个简单的控制器和视图,然后部署到 Azure。从 Azure 打开网站会产生错误:

Connection string "DefaultConnection" was not found.
Line 2:       if (!WebSecurity.Initialized)
Line 3:      {
Line 4:          WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId",
Line 5:                                                   "UserName", autoCreateTables: true);
Line 6:      }
Source File: c:DWASFilessitespreVirtualDirectory0sitewwwroot_AppStart.cshtml    Line: 4 

为什么空项目试图引用网络安全/数据库/等?

为什么我在具有全局搜索的项目中找不到此代码?

任何帮助将不胜感激。我想我正在失去理智。

您的测试网站似乎继承了 machine.config 的成员资格提供程序。尝试将此元素添加到 web.config 中的<system.web>元素中

<membership>
  <providers>
      <clear />
  </providers>
</membership>
<roleManager enabled="false">
  <providers>
      <clear />
  </providers>
</roleManager>
<profile enabled="false">
   <providers>
       <clear />
     </providers>
</profile>

还要添加这个:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="RoleManager" />
    </modules>
</system.webServer>

我发现了问题。我在以前部署的根目录中有一些文件,这些文件在部署时未被删除。完全与代码无关。

相关内容

最新更新