在应用程序级别之外注册为allowDefinition ='MachineToApplication'的部分

Ker*_*eks 8 asp.net directory virtual entity-framework

将System.Data.Entity组合添加到我的Web配置后,我遇到了这个错误:使用注册为allowDefinition ='MachineToApplication'的部分超出应用程序级别是错误的.此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的.

我删除了obj和bin文件夹,我删除了行身份验证="windows",尝试重新打开,因为有人说它有效,我检查了主文件夹中只有1个web.config(实体框架 - 文件夹形式,型号,DAL和BLL)......

还有什么其他原因会发生这种情况?我到处搜索,这基本上是我发现的上述原因....

这是我的web.config,如果它有所不同:

    <configuration>
  <connectionStrings>
    <add name="ApplicationServices"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />
    <add name="CStringVKB" connectionString="Data Source=.;Initial Catalog=VKB;Persist Security Info=True;User ID=websiteservice;Password=websiteservice" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" optimizeCompilations="true" targetFramework="4.0" >
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <!--<authentication mode="Windows">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>-->
     <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>
   <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
  </system.web>
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个问题?

Chr*_*kis 23

基本上,错误意味着您的一个子文件夹中有一个web.config文件,该文件具有不应具有的配置元素.这是你的root/only web配置文件吗?如果没有,你也可以发布这些吗?

此外,它听起来很愚蠢,但我会仔细检查你在IDE中打开网站本身(而不是错误地打开父文件夹)我看到人们花了几个小时试图调试同样的错误,当他们一直在不在正确的目录中.

以下是关于如何为ASP设置web.config层次结构的一个很好的解释,它将帮助您可视化其工作原理:http: //scottonwriting.net/sowblog/archive/2010/02/17/163375.aspx