c# – 使用Azure表存储的BotAuth出错
发布时间:2020-12-15 22:49:18 所属栏目:百科 来源:网络整理
导读:我正在使用 BotAuth nuget包登录我的机器人用户.最近,我按照 https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage中提到的步骤实现了Azure Table存储来存储和管理机器人的状态数据. 我的Global.asax.cs文
|
我正在使用
BotAuth nuget包登录我的机器人用户.最近,我按照
https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage中提到的步骤实现了Azure Table存储来存储和管理机器人的状态数据.
我的Global.asax.cs文件如下所示: public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
var store = new TableBotDataStore(CloudStorageAccount.DevelopmentStorageAccount);
Conversation.UpdateContainer(builder =>
{
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,CachingBotDataStoreConsistencyPolicy
.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
});
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
而MessagesController与bot模板中的相同: [BotAuthentication]
public class MessagesController : ApiController
{
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity,() => new Dialogs.RootDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
private Activity HandleSystemMessage(Activity message)
{ ...... }
}
现在,在测试它时,我按预期获得了登录卡,在点击并完成授权过程后,我在浏览器中收到以下错误: {
"message": "An error has occurred.","exceptionMessage": "Object reference not set to an instance of an object.","exceptionType": "System.NullReferenceException","stackTrace": " at BotAuth.AADv1.ADALAuthProvider.<GetTokenByAuthCodeAsync>d__4.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)rn at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()rn at BotAuth.Controllers.CallbackController.<Callback>d__3.MoveNext()"
}
我到底错过了什么?是一些autofac模块注册.有没有人有这方面的工作样本. 解决方法
正如@FeiHan在评论中指出的那样,这是一个公开的问题,在
richdizz/BotAuth. –
“Enabling custom state service causes authentication failure”.
此问题已于MicrosoftDX/botauth修复,因此首选使用此问题 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
