ASP.NET无法访问IIS上具有角色权限的页面

时间:2014-06-10 15:28:59

标签: c# asp.net sql iis login

我已经使用默认登录系统创建了一个应用程序,并创建了一个文件夹" Client"只有管​​理员才有权访问。我把我的网站放在IIS上并修复了一些登录错误,我需要授予NT AUTHORITY \ NETWORK SERVICE用户权限。

现在我正在处理我之前遇到的下一个错误,但我不确定如何处理它。我似乎可以登录,但是当我尝试导航到Client文件夹时,我收到此错误。

Configuration Error

Description: An error occurred during the processing of a configuration file 
required to service this request. Please review the specific error details below 
and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'System.Web.Providers, 
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its 
dependencies. The system cannot find the file specified.

我做了一些搜索,看起来有些人说:

"使用此NuGet命令自动安装DLL:     安装包Microsoft.AspNet.Providers.Core"

我运行了该命令,现在不仅Client文件夹给我错误,每个页面都给我错误。

这是我的配置:

<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ClientInfo-20140530090429;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ClientInfo-20140530090429.mdf" providerName="System.Data.SqlClient" />
<add name="clientConnection" connectionString="Data Source=EDITOR1;Initial Catalog=info;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="CLIENT" connectionString="Data Source=EDITOR1;Initial Catalog=clientInformation;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5.1">
  <assemblies>
    <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
  </assemblies>
 </compilation>
 <httpRuntime targetFramework="4.5.1" />
 <pages>
  <namespaces>
    <add namespace="System.Web.Optimization" />
  </namespaces>
  <controls>
    <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
  </controls>
  </pages>
  <authentication mode="Forms">
  <forms loginUrl="~/Authenticate.aspx" timeout="2880" />
 </authentication>
 <profile defaultProvider="DefaultProfileProvider">
  <providers>
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
  </profile>
  <membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
 </membership>
 <roleManager enabled="true" defaultProvider="DefaultRoleProvider">
  <providers>
    <add connectionStringName="DefaultConnection" applicationName="/" name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </providers>
  </roleManager>
  <!--
        If you are deploying to a cloud environment that has multiple web server instances,
        you should change session state mode from "InProc" to "Custom". In addition,
        change the connection string named "DefaultConnection" to connect to an instance
        of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
  -->
 <sessionState mode="InProc" customProvider="DefaultSessionProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
  </providers>
  </sessionState>
 <identity impersonate="false" />
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<appSettings>
<add key="DirectoryPath" value="LDAP://srv-sbs.fs.local/dc=fs,dc=local" />
<add key="DirectoryDomain" value="SRV-SBS.fs.local" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

1 个答案:

答案 0 :(得分:1)

您的<ConfigSections>没有System.Web.Providers的条目。以与实体框架相同的方式插入它。像:

插入以下提供者:

<providers>
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>

加入某些标签,例如<Entity></Entity>.

然后在顶部的部分中定义它:

&LT; ConfigSections> <section name="Entity" type="System.Web.Providers" ______________/> </ConfigSections>

以与实体框架相同的方式完全填写它。

在visual studio命令提示符下使用命令sn -T检查DLL的确切公钥标记,并在ConfigSections中插入条目。

更好的选择是:有一个小的exe应用程序EnterpriseLibray.Config ..(不知道完整的名称.Google it ..)。如果为程序集运行此应用程序,它会自动将与dll相关的必需条目插入到web.config所需的位置。