【发布时间】:2016-04-19 07:21:52
【问题描述】:
我关注了这个guide to write my own Katana authentication middleware。
现在我在编写 AuthenticationOptions 时遇到了一个问题。 当我从 Microsoft.Owin.Security.AuthenticationOptions 固有时,我得到“由于其保护级别而无法访问”。问题是这个类是受保护的,所以它不应该是不可访问的?我试图做一个干净和重建,但我仍然得到同样的错误。我一定是错过了什么?
我的班级:
using Microsoft.Owin;
using Microsoft.Owin.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dummy
{
public class DummyAuthenticationOptions : AuthenticationOptions
{
public DummyAuthenticationOptions(string userName, string userId)
: base(Constants.DefaultAuthenticationType)
{
Description.Caption = Constants.DefaultAuthenticationType;
CallbackPath = new PathString("/signin-dummy");
AuthenticationMode = AuthenticationMode.Passive;
UserName = userName;
UserId = userId;
}
public PathString CallbackPath { get; set; }
public string UserName { get; set; }
public string UserId { get; set; }
public string SignInAsAuthenticationType { get; set; }
public ISecureDataFormat<AuthenticationProperties> StateDataFormat { get; set; }
}
}
Microsoft.Owin.Security.AuthenticationOptions:
namespace Microsoft.Owin.Security
{
internal abstract class AuthenticationOptions
{
protected AuthenticationOptions(string authenticationType);
public AuthenticationMode AuthenticationMode { get; set; }
public string AuthenticationType { get; set; }
public AuthenticationDescription Description { get; set; }
}
}
【问题讨论】:
-
内部类只能从声明它们的程序集中访问。您确定您使用的
Microsoft.Owin.Security与本文作者使用的版本相同吗?我刚刚从 github 打开了作者示例的源代码,那里的一切看起来都很好。AuthenticationOptions类在该版本的库 (2.0.1+) 中是公共的。 -
我正在使用最新的稳定版 (3.0.1)。如果有任何帮助,我将使用 nuget 获取软件包。我降级到 2.0.1 并编译。我想问题是这个类是内部的,它不在 2.0.1 中,我想知道为什么?谢谢你帮助我:)
标签: c# inheritance visual-studio-2015 owin katana