Base solution for your next web application
Open Closed

ASP.NET Core + Angular 6.5 Development Token Error #6349


User avatar
0
mdframe created

Ever since we upgraded to v6.5 I get a debugging stop in the following function at the hi-lighted line. I have cleared cached and done other things but it still persists. What needs to be cleared to stop this from happening?

 /* This method is needed to authorize SignalR javascript client.
         * SignalR can not send authorization header. So, we are getting it from query string as an encrypted text. */
        private static Task QueryStringTokenResolver(MessageReceivedContext context)
        {
            if (!context.HttpContext.Request.Path.HasValue)
            {
                return Task.CompletedTask;
            }

            if (context.HttpContext.Request.Path.Value.StartsWith("/signalr"))
            {
                var env = context.HttpContext.RequestServices.GetService<IHostingEnvironment>();
                var config = env.GetAppConfiguration();
                **Debug Breaks Here ---> ** var allowAnonymousSignalRConnection = bool.Parse(config["App:AllowAnonymousSignalRConnection"]);
                
                return SetToken(context, allowAnonymousSignalRConnection);
            }

            if (context.HttpContext.Request.Path.Value.Contains("/Chat/GetUploadedObject"))
            {
                return SetToken(context, false);
            }

            return Task.CompletedTask;
        }

System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. Parameter name: value Source=System.Private.CoreLib StackTrace: at System.Boolean.Parse(String value) at F2TEK.SKUHive.Web.Startup.AuthConfigurer.QueryStringTokenResolver(MessageReceivedContext context) in D:\Projects\C-Sharp\SKUHive\aspnet-core\src\F2TEK.SKUHive.Web.Host\Startup\AuthConfigurer.cs:line 86 at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.<HandleAuthenticateAsync>d__6.MoveNext()

This occurs for each call back into the web services and is very painful to step over every time you refresh the screen or change menu options in development. We don't seem to see it occur in our QA environment however that is a release version so we assume it is something to do with a record in the database or some token left over prior to the release.

Thx


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    You need AllowAnonymousSignalRConnection setting in appsettings.json. It was added in ASP<span></span>.NET Zero v6.4.

  • User Avatar
    0
    mdframe created

    Aaron,

    Thanks so much! We definitely missed that in the last release.

    Thanks again,

    Matt