ISecureDataFormat<AuthenticationTicket>
autofacを使って登録するには?Autofacを使ってISecureDataFormat <AuthenticationTicket>を登録する
私は、このように登録してみてください:
builder.RegisterType<SecureDataFormat<AuthenticationTicket>>()
.As<ISecureDataFormat<AuthenticationTicket>>()
.InstancePerLifetimeScope();
を私はエラーを取得:
An error occurred when trying to create a controller of type 'AccountController'. Make sure that the controller has a parameterless public constructor. ....
InnerException":{"Message":"An error has occurred.","ExceptionMessage":"None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Microsoft.Owin.Security.DataHandler.SecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]' can be invoked with the available services and parameters
AccountController.csすべてが動作しているコンストラクタでISecureDataFormat<AuthenticationTicket> accessTokenFormat
なし
public AccountController(ApplicationUserManager _userManager,
IAuthenticationManager authenticationManager,
ISecureDataFormat<AuthenticationTicket> accessTokenFormat)
{
this._userManager = _userManager;
this._authenticationManager = authenticationManager;
this._accessTokenFormat = accessTokenFormat;
}
。
SecureDataFormat
#region
Assembly Microsoft.Owin.Security, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
#endregion
using Microsoft.Owin.Security.DataHandler.Encoder;
using Microsoft.Owin.Security.DataHandler.Serializer;
using Microsoft.Owin.Security.DataProtection;
namespace Microsoft.Owin.Security.DataHandler
{
public class SecureDataFormat<TData> : ISecureDataFormat<TData>
{
public SecureDataFormat(IDataSerializer<TData> serializer, IDataProtector protector, ITextEncoder encoder);
public string Protect(TData data);
public TData Unprotect(string protectedText);
}
}
AuhenticationTicket
#region
Assembly Microsoft.Owin.Security, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
#endregion
using System.Security.Claims;
namespace Microsoft.Owin.Security
{
public class AuthenticationTicket
{
public AuthenticationTicket(ClaimsIdentity identity, AuthenticationProperties properties);
public ClaimsIdentity Identity { get; }
public AuthenticationProperties Properties { get; }
}
}
* Autofac *は 'SecureDataFormat 'を作成できないため、コンストラクタを共有できますか? –
@CyrilDurand私はポストを更新します。このクラスは、owinからです。 – user1031034