Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Asp.net核心Url.Action()未命中我的控制器方法_C#_Asp.net_Asp.net Core - Fatal编程技术网

C# Asp.net核心Url.Action()未命中我的控制器方法

C# Asp.net核心Url.Action()未命中我的控制器方法,c#,asp.net,asp.net-core,C#,Asp.net,Asp.net Core,我花了很长时间试图弄清楚为什么ExternalLoginCallback方法中的断点没有被命中 以下是我的AccountController中的代码: [HttpPost] [AllowAnonymous] public IActionResult ExternalLogin(string provider, string returnUrl) { var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new {

我花了很长时间试图弄清楚为什么
ExternalLoginCallback
方法中的断点没有被命中

以下是我的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("~/");
}
[HttpPost]
[异名]
公共IActionResult外部登录(字符串提供程序、字符串返回URL)
{
var redirectUrl=Url.Action(“ExternalLoginCallback”,“Account”,new{ReturnUrl=ReturnUrl});
var properties=signInManager.ConfigureExternalAuthenticationProperties(提供程序,重定向URL);
返回新的ChallengeResult(提供程序、属性);
}
[HttpPost]
[异名]
公共异步任务ExternalLoginCallback(string returnUrl=null,string remoteError=null)
{
returnUrl=returnUrl??Url.Content(“~/”);
}
我已经在
Url.Action()
中指定了方法名、控制器名和参数,但是没有命中
ExternalLoginCallback
为什么


我已尝试删除
remoteError
参数,但它仍然不会被命中。

首先,您的方法ExternalLoginCallback希望收到参数“returnUrl”,而您正在发布“returnUrl”(大写)


您可以尝试其他测试,例如将ExternalLoginCallback方法更改为接收GET而不是POST…

您不能通过导航到其他URL来使用POST。只有在提交某些数据时,使用POST才有意义。代码中不清楚实际发布的数据是什么。哦,是的,你是对的。我删除了HttpPost属性。