仅使用1个GET时出现“ AmbiguousActionException:多个动作匹配”

时间:2018-10-02 22:34:45

标签: c# razor-pages

即使页面上只有一个GET,我仍收到此错误。所以我很困惑。

这是整个登录页面的外观:

public class LoginModel : PageModel
{
private UserAuthenticationService _userAuthenticationService { get; set; }
private ClaimService _claimService { get; set; }

public LoginModel(UserAuthenticationService userAuthenticationService, ClaimService claimService)
{
    _userAuthenticationService = userAuthenticationService;
    _claimService = claimService;
}

public async Task OnGetAsync()
{
    var user = _userAuthenticationService.Login();
    if (user == null)
    {
        //TODO: Login failed
    }
    else
    {
        var claims = _claimService.GetClaimsFromUserModel(user);
        var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

        var authProperties = new AuthenticationProperties()
        {
            ExpiresUtc = DateTime.UtcNow.AddDays(6),
            IsPersistent = true,
        };
        await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), authProperties);
    }
}

这是错误。我只有一个OnGet,所以我不知道为什么它说有多个。有什么想法吗?

enter image description here

0 个答案:

没有答案