【问题标题】:Razor view returns empty when using Authorize attrib on controller在控制器上使用 Authorize 属性时,Razor 视图返回空
【发布时间】:2018-04-28 17:27:22
【问题描述】:

尝试在 iis 10 上托管的 asp.net core 2 项目中设置身份验证时,我从 Login.cshtml 得到一个空页面和这个异常(配置 web.config 以写入日志)。

fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
      An error occurred while reading the key ring.
System.UnauthorizedAccessException: Access to the path 'C:\Windows\system32\config\systemprofile\AppData\Local\ASP.NET\DataProtection-Keys\key-a269af3e-9a68-43f4-95c0-0dbebb957639.xml' is denied.
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileA...

Web.config 写入日志:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
      <!--on iis 10-->
      <aspNetCore
        processPath="dotnet"
        arguments=".\GotoLink.Web.dll"
        stdoutLogEnabled="true"
        stdoutLogFile=".\logs\stdout" />
    </system.webServer>
</configuration>

如何使身份验证起作用?

【问题讨论】:

    标签: asp.net-core-2.0 iis-10


    【解决方案1】:

    结果很容易解决:

    请参阅“数据保护” https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x#data-protection

    我选择了选项 2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多