简体   繁体   中英

Asp.net Core Url.Action() does not hit my controller method

I have spent quite a while trying to figure out why my breakpoint in the ExternalLoginCallback method is not being hit.

Below is my code inside my AccountController:

[HttpPost]
[AllowAnonymous]
public IActionResult ExternalLogin(string provider, string returnUrl)
{
    var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl});
    var properties = signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
    return new ChallengeResult(provider, properties);
}

[HttpPost]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
    returnUrl = returnUrl ?? Url.Content("~/");
}

I have specified the method name, controller name and parameter inside Url.Action() but ExternalLoginCallback is not being hit why is this?

I have tried removing the remoteError parameter, but it still will not get hit.

First of all, your method ExternalLoginCallback expects to receive the parameter "returnUrl" and you are posting "ReturnUrl" (uppercase).

You can try other tests, like change the method ExternalLoginCallback to receive a GET instead a POST...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM