Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.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# 使用BotAuth时如何正确注销_C#_Botframework - Fatal编程技术网

C# 使用BotAuth时如何正确注销

C# 使用BotAuth时如何正确注销,c#,botframework,C#,Botframework,使用时,注销现有已登录用户的正确方法是什么?在中,它是使用await context.Logout()完成的 在浏览BotAuth时,我发现以下代码正在注销,但在任何示例中都没有显示 public async Task Logout(AuthenticationOptions authOptions, IDialogContext context) { context.UserData.RemoveValue($"{this.Name}{ContextConstants.

使用时,注销现有已登录用户的正确方法是什么?在中,它是使用
await context.Logout()完成的

在浏览BotAuth时,我发现以下代码正在注销,但在任何示例中都没有显示

public async Task Logout(AuthenticationOptions authOptions, IDialogContext context)
    {
        context.UserData.RemoveValue($"{this.Name}{ContextConstants.AuthResultKey}");
        context.UserData.RemoveValue($"{this.Name}{ContextConstants.MagicNumberKey}");
        context.UserData.RemoveValue($"{this.Name}{ContextConstants.MagicNumberValidated}");
        string signoutURl = "https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=" + System.Net.WebUtility.UrlEncode(authOptions.RedirectUrl);
        await context.PostAsync($"In order to finish the sign out, please click at this [link]({signoutURl}).");
    }
在调用上述函数时,尽管userdata已清除,但仍出现以下错误:
这是注销的正确方式吗?

我发现返回的URL将是
http://localhost:3979/Callback
(没有任何查询字符串)在我完成注销操作后,在中,我发现它直接返回异常,状态为BadRequest

[HttpGet]
[Route("Callback")]
public async Task<HttpResponseMessage> Callback()
{
    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new Exception());
}
测试结果:

[HttpGet]
[Route("Callback")]
public async Task<HttpResponseMessage> Callback()
{
    //return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new Exception());

    var resp = new HttpResponseMessage(HttpStatusCode.OK);
    resp.Content = new StringContent("<html><body>Logout success</body></html>", System.Text.Encoding.UTF8, @"text/html");
    return resp;
}