Azure Web PubSub与服务端认证:ASP.NET端点验证位置咨询
如何在ASP.NET应用中验证Azure Web PubSub的简易认证码?
我有一个作为事件处理服务的简易ASP.NET应用,现有代码如下:
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services .AddWebPubSub(options => options.ServiceEndpoint = new ServiceEndpoint(WebPubSubConnectionString)) .AddWebPubSubServiceClient<WebPubSubHub>(); WebApplication app = builder.Build(); app.MapWebPubSubHub<WebPubSubHub>("/eventhandler"); app.Run();
我已在Azure Web PubSub中配置了Webhook URL,并采用Azure建议的简易认证码方案保护公开的/eventhandler端点,配置的URL模板为:
https://a9e5-92-253-212-316.ngrok-free.app/eventhandler?code=RRRRR
我尝试直接将带认证码的URL映射到Hub:
app.MapWebPubSubHub<WebPubSubHub>("/eventhandler?code=RRRRR")
但触发了如下异常:
Microsoft.AspNetCore.Routing.Patterns.RoutePatternException: 'The literal section 'eventhandler?code=RRRRR' is invalid. Literal sections cannot contain the '?' character.'
请问在ASP.NET应用中应该在哪里验证这个认证码?
内容的提问来源于stack exchange,提问作者Darkside
相关产品推荐
相关产品推荐

