Posts

Showing posts from July, 2020

Authentication with ASP.NET Identity and JWT in the same project

Image
This article describes how to add JWT Tokens to a project that is already configured for using ASP.NET Identity. This will allow you to build a website that will also support a mobile app or SPA pointing to API's in the same solution. To test the implementation it is a good idea to setup up a test API controller that just returns a couple of values. Here is an example of the base test controller functionality. [ Route ( " api/[controller] " )] [ ApiController ] public class ValuesController : ControllerBase { [ HttpGet ] public List < string > GetValues () { return new List < string >() { " Value1 " , " Value2 " }; } } Since this doesn't have any authentication configured yet, you can test this in a standard browser and you should receive the list of values on the page. Next you will want to add the [Authorize] attribute to the controller and test that you are redirecte