{"action":"created","issue":{"url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/1","repository_url":"https://api.github.com/repos/e5Workflow/CoreWebApp","labels_url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/1/comments","events_url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/1/events","html_url":"https://github.com/e5Workflow/CoreWebApp/issues/1","id":360313473,"node_id":"MDU6SXNzdWUzNjAzMTM0NzM=","number":1,"title":"\"Suitable constructor not found\" on Asp.net core 2.1","user":{"login":"BodaciousDrake","id":632644,"node_id":"MDQ6VXNlcjYzMjY0NA==","avatar_url":"https://avatars0.githubusercontent.com/u/632644?v=4","gravatar_id":"","url":"https://api.github.com/users/BodaciousDrake","html_url":"https://github.com/BodaciousDrake","followers_url":"https://api.github.com/users/BodaciousDrake/followers","following_url":"https://api.github.com/users/BodaciousDrake/following{/other_user}","gists_url":"https://api.github.com/users/BodaciousDrake/gists{/gist_id}","starred_url":"https://api.github.com/users/BodaciousDrake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BodaciousDrake/subscriptions","organizations_url":"https://api.github.com/users/BodaciousDrake/orgs","repos_url":"https://api.github.com/users/BodaciousDrake/repos","events_url":"https://api.github.com/users/BodaciousDrake/events{/privacy}","received_events_url":"https://api.github.com/users/BodaciousDrake/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-14T13:51:31Z","updated_at":"2018-09-14T15:18:44Z","closed_at":null,"author_association":"NONE","body":" @e5enrico I've been banging my head on the desk for two days trying to fix the problem you described here, so thanks for your work on this. I have made all the relevant changes in my project, but I'm getting an error saying it can't find a suitable constructor for the \"AuthenticationMiddleware\" type when the app is attempting to start (using asp.net core 2.1). \r\n\r\nAny ideas? \r\n\r\n```\r\nSystem.InvalidOperationException: A suitable constructor for type 'GntyAPI.AuthenticationMiddleware' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.\r\n   at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)\r\n   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.<UseMiddleware>b__0(RequestDelegate next)\r\n   at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()\r\n   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()\r\n```"},"comment":{"url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/comments/421392175","html_url":"https://github.com/e5Workflow/CoreWebApp/issues/1#issuecomment-421392175","issue_url":"https://api.github.com/repos/e5Workflow/CoreWebApp/issues/1","id":421392175,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTM5MjE3NQ==","user":{"login":"BodaciousDrake","id":632644,"node_id":"MDQ6VXNlcjYzMjY0NA==","avatar_url":"https://avatars0.githubusercontent.com/u/632644?v=4","gravatar_id":"","url":"https://api.github.com/users/BodaciousDrake","html_url":"https://github.com/BodaciousDrake","followers_url":"https://api.github.com/users/BodaciousDrake/followers","following_url":"https://api.github.com/users/BodaciousDrake/following{/other_user}","gists_url":"https://api.github.com/users/BodaciousDrake/gists{/gist_id}","starred_url":"https://api.github.com/users/BodaciousDrake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BodaciousDrake/subscriptions","organizations_url":"https://api.github.com/users/BodaciousDrake/orgs","repos_url":"https://api.github.com/users/BodaciousDrake/repos","events_url":"https://api.github.com/users/BodaciousDrake/events{/privacy}","received_events_url":"https://api.github.com/users/BodaciousDrake/received_events","type":"User","site_admin":false},"created_at":"2018-09-14T15:18:44Z","updated_at":"2018-09-14T15:18:44Z","author_association":"NONE","body":"It must be a difference in the way that middleware is implemented in later versions of asp.net core. I picked from your code and got this to work by adding the following as the first middleware in my `startup.cs`: \r\n\r\n           ```\r\n app.Use(async (context, next) =>\r\n            {\r\n                if(context.Request.Method != \"OPTIONS\" && !context.User.Identity.IsAuthenticated)\r\n                {\r\n                    context.Response.StatusCode = 401;\r\n                    await context.Response.WriteAsync(\"Not Authenticated\");\r\n                }\r\n                await next.Invoke();\r\n            });\r\n```"}}
{"actor":{"display_login":"BodaciousDrake"}}