简体   繁体   English

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

[英]ASP.NET Can't access pages with role permissions on IIS

I've created an application with the default login system and created a folder "Client" that only administrators should have access to. 我已经使用默认的登录系统创建了一个应用程序,并创建了一个只有管理员才能访问的文件夹“ Client”。 I put my site on IIS and fixed some login errors in which I needed to grant the NT AUTHORITY\\NETWORK SERVICE user permission. 我将站点放在IIS上,并修复了一些登录错误,在这些错误中,我需要授予NT AUTHORITY \\ NETWORK SERVICE用户权限。

Now I'm dealing with this next error, which I've encountered before, but I'm not sure how to deal with it. 现在,我正在处理下一个错误,这是我之前遇到的,但是我不确定如何处理。 It appears that I can login, but when I try to navigate to the Client folder, I get this error. 看来我可以登录,但是当我尝试导航到“客户端”文件夹时,出现此错误。

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.

I did some searching and it looked like some people said to: 我做了一些搜索,看起来有些人说:

"Use this NuGet command to install your DLL automatically: Install-Package Microsoft.AspNet.Providers.Core" “使用此NuGet命令自动安装DLL:Install-Package Microsoft.AspNet.Providers.Core”

I ran that command, and now not only does the Client folder give me that error, every page gives me that error. 我运行了该命令,现在Client文件夹不仅给我该错误,每个页面也给我该错误。

Here's my config: 这是我的配置:

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

your <ConfigSections> doesn't have entry for System.Web.Providers. 您的<ConfigSections>没有System.Web.Providers的条目。 Insert it in the same way you've done for entityframework. 以与完成实体框架相同的方式插入它。 Like: 喜欢:

Insert the providers written below: 插入下面提供的提供程序:

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

Into some tag like <Entity></Entity>. 放入诸如<Entity></Entity>.类的标签中<Entity></Entity>.

Then define it in the section on top like: 然后在顶部的部分中对其进行定义,如下所示:

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

Completely fill it in the same way as done for entity framework. 完全按照与实体框架相同的方式填充它。

Check the exact public key token for the DLL using command sn -T on visual studio command prompt and insert entry into ConfigSections. 在Visual Studio命令提示符下使用命令sn -T检查DLL的确切公钥令牌,然后将条目插入ConfigSections。

The better option is: there is a small exe application EnterpriseLibray.Config..(Don't know the complete name. Google it..). 更好的选择是:有一个小的exe应用程序EnterpriseLibray.Config ..(不知道完整名称。 If you run this application for assemblies it automatically insert the required entries related to the dll into the desired places of web.config. 如果为组装运行此应用程序,它将自动将与dll相关的所需条目插入到web.config的所需位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM