{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Home/issues/2591","repository_url":"https://api.github.com/repos/aspnet/Home","labels_url":"https://api.github.com/repos/aspnet/Home/issues/2591/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Home/issues/2591/comments","events_url":"https://api.github.com/repos/aspnet/Home/issues/2591/events","html_url":"https://github.com/aspnet/Home/issues/2591","id":285340486,"node_id":"MDU6SXNzdWUyODUzNDA0ODY=","number":2591,"title":"Passing more than Status Code to the Error action","user":{"login":"aspnet-hello","id":34947467,"node_id":"MDQ6VXNlcjM0OTQ3NDY3","avatar_url":"https://avatars3.githubusercontent.com/u/34947467?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet-hello","html_url":"https://github.com/aspnet-hello","followers_url":"https://api.github.com/users/aspnet-hello/followers","following_url":"https://api.github.com/users/aspnet-hello/following{/other_user}","gists_url":"https://api.github.com/users/aspnet-hello/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet-hello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet-hello/subscriptions","organizations_url":"https://api.github.com/users/aspnet-hello/orgs","repos_url":"https://api.github.com/users/aspnet-hello/repos","events_url":"https://api.github.com/users/aspnet-hello/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet-hello/received_events","type":"User","site_admin":false},"labels":[{"id":792347802,"node_id":"MDU6TGFiZWw3OTIzNDc4MDI=","url":"https://api.github.com/repos/aspnet/Home/labels/repo:Diagnostics","name":"repo:Diagnostics","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/aspnet/Home/milestones/5","html_url":"https://github.com/aspnet/Home/milestone/5","labels_url":"https://api.github.com/repos/aspnet/Home/milestones/5/labels","id":3005291,"node_id":"MDk6TWlsZXN0b25lMzAwNTI5MQ==","number":5,"title":"Backlog","description":null,"creator":{"login":"aspnet-hello","id":34947467,"node_id":"MDQ6VXNlcjM0OTQ3NDY3","avatar_url":"https://avatars3.githubusercontent.com/u/34947467?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet-hello","html_url":"https://github.com/aspnet-hello","followers_url":"https://api.github.com/users/aspnet-hello/followers","following_url":"https://api.github.com/users/aspnet-hello/following{/other_user}","gists_url":"https://api.github.com/users/aspnet-hello/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet-hello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet-hello/subscriptions","organizations_url":"https://api.github.com/users/aspnet-hello/orgs","repos_url":"https://api.github.com/users/aspnet-hello/repos","events_url":"https://api.github.com/users/aspnet-hello/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet-hello/received_events","type":"User","site_admin":false},"open_issues":158,"closed_issues":17,"state":"open","created_at":"2018-01-01T07:20:36Z","updated_at":"2018-10-01T21:44:32Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2018-01-02T00:51:51Z","updated_at":"2018-10-08T17:51:29Z","closed_at":null,"author_association":"NONE","body":"_From @Ciantic on Thursday, July 14, 2016 4:19:35 AM_\r\n\r\nCurrently there is a problem with the way JSON error results are handled e.g.: https://github.com/aspnet/Security/issues/872 and https://github.com/aspnet/Security/issues/699 there is no easy way to pass more than status code to your Error action that shows the error page or JSON result.\n\nSometimes it would be nice to have a reason in the result e.g. \"Insufficient rights, because you are not an employee\" or in JSON `{ \"error\" : \"FORBIDDEN\", \"requires\" : [\"EmployeeOnly\"] }` to show a dialog why you are forbidden to see the page. \n\nBut since only thing the error handler gets is the status code it can't determine the extra requirement, claim in this case.\n\nImagine the situation that you have this:\n\n``` C#\nservices.AddAuthorization(opts => {\n    // ...\n    opts.AddPolicy(\"EmployeeOnly\", policy => {\n        policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme);\n        policy.RequireClaim(\"EmployeeNumber\");\n    });\n});\n```\n\nThen this as a Error handler for status code pages:\n\n``` C#\n[HttpGet(\"/Error\"), HttpPost(\"/Error\")]\npublic IActionResult Error([FromQuery] int status = 400)\n{\n    if (HttpContext.Request.Headers.ContainsKey(\"Accept\") && \n        HttpContext.Request.Headers[\"Accept\"].Contains(\"application/json\"))\n    { \n        if (status == 403) { \n            // PROBLEM: There is no way to get the failing reason (e.g. claim \"EmployeeOnly\") here? \n            return new JsonResult(new { error = \"FORBIDDEN\" });\n        }\n        else\n        {\n            return new JsonResult(new { error = \"UNDEFINED_ERROR\" });\n        }\n    }\n    // HTML Version if you wish ...\n}\n```\n\r\n\r\n_Copied from original issue: aspnet/Diagnostics#316_"},"comment":{"url":"https://api.github.com/repos/aspnet/Home/issues/comments/427923304","html_url":"https://github.com/aspnet/Home/issues/2591#issuecomment-427923304","issue_url":"https://api.github.com/repos/aspnet/Home/issues/2591","id":427923304,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzkyMzMwNA==","user":{"login":"blowdart","id":796298,"node_id":"MDQ6VXNlcjc5NjI5OA==","avatar_url":"https://avatars2.githubusercontent.com/u/796298?v=4","gravatar_id":"","url":"https://api.github.com/users/blowdart","html_url":"https://github.com/blowdart","followers_url":"https://api.github.com/users/blowdart/followers","following_url":"https://api.github.com/users/blowdart/following{/other_user}","gists_url":"https://api.github.com/users/blowdart/gists{/gist_id}","starred_url":"https://api.github.com/users/blowdart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blowdart/subscriptions","organizations_url":"https://api.github.com/users/blowdart/orgs","repos_url":"https://api.github.com/users/blowdart/repos","events_url":"https://api.github.com/users/blowdart/events{/privacy}","received_events_url":"https://api.github.com/users/blowdart/received_events","type":"User","site_admin":false},"created_at":"2018-10-08T17:51:29Z","updated_at":"2018-10-08T17:51:29Z","author_association":"MEMBER","body":"Move it to 3, it's still often requested"}}
{"actor":{"display_login":"blowdart"}}