0
メソッドSignInが呼び出されると、NullReferenceExepctionエラーが発生します。ここでDotVVM認証でヌル例外が発生する
は私のViewModelである:ここでは
public Masterpage1ViewModel() {
UserIdentity user = new UserIdentity("Admin");
var claimsIdentity = new ClaimsIdentity(user);
Context.OwinContext.Authentication.SignIn(claimsIdentity);
}
がUserIdentityためのクラスです:
public class UserIdentity : IIdentity
{
public string AuthenticationType
{
get { return DefaultAuthenticationTypes.ApplicationCookie; }
}
public bool IsAuthenticated { get; set; }
public string Name { get; private set; }
public UserIdentity(string name)
{
Name = name;
}
}
また、私はStartup.csに追加:
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
Provider = new CookieAuthenticationProvider()
{
OnApplyRedirect = e => DotvvmAuthenticationHelper.ApplyRedirectResponse(e.OwinContext, e.RedirectUri)
}
});