我的控制器具有以下功能。我正在尝试让“ MethodAsync”为“ CallbackAsync”方法创建一个回调URL。
对于thirdPartyCallbackUrl 0到3,我得到了正确的URL。但是,对于4到7,我得到一个空值。我不知道发生了什么。
[Route("auth")]
[ApiController]
public class AuthController : Controller
{
[HttpGet("othermethod")]
public async Task<IActionResult> OtherMethod()
{
return Ok();
}
[HttpGet("third-party-callback")]
public async Task<IActionResult> CallbackAsync()
{
return Ok();
}
[HttpPost("third-party-login/{loginType}")]
public async Task<IActionResult> MethodAsync()
{
string thirdPartyCallbackUrl = Url.ActionLink(action: nameof(CallbackAsync));
string thirdPartyCallbackUrl1 = Url.ActionLink(action: nameof(CallbackAsync), controller: "Auth");
string thirdPartyCallbackUrl2 = Url.ActionLink(action: "CallbackAsync", controller: "Auth");
string thirdPartyCallbackUrl3 = Url.ActionLink(action: "CallbackAsync");
string thirdPartyCallbackUr4 = Url.ActionLink(action: nameof(OtherMethod));
string thirdPartyCallbackUrl5 = Url.ActionLink(action: nameof(OtherMethod), controller: "Auth");
string thirdPartyCallbackUrl6 = Url.ActionLink(action: "OtherMethod", controller: "Auth");
string thirdPartyCallbackUrl7 = Url.ActionLink(action: "OtherMethod");
...
}
}
答案 0 :(得分:0)
原来,我的“ CallbackAsync”方法的“ Async”后缀有问题。我一放下,一切就正常了。