.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
with html pages you use cookie authentication. this can be combined with bearer. just add cookie authentication to the project. You can use scheme with the authorize to allow both or just one scheme.
Member
1 Points
1 Post
ASP Net Core (2.1) WebApp with API AND secure HTML pages
Nov 15, 2019 05:47 AM|GFrancis|LINK
I've created an AspNetCore(2.1) WebApp that has an API controller secured using JwtBearer authentication.
In
ConfigureServices
I have:services.AddAuthentication(...).AddJwtBearer(...)
In my API Controller I have:
[Authorize]
[ApiController]
public class BillingController : ControllerBase
{ ...
This all works perfectly well.
Now I want to add some HTML pages to the WebApp that are secured by 'traditional' sessions.
These pages will contain javascript/ajax that will also call the API methods to gather data.
Is there a recommended approach/template/example for combining these authentication methods?
Contributor
2690 Points
874 Posts
Re: ASP Net Core (2.1) WebApp with API AND secure HTML pages
Nov 18, 2019 07:36 AM|Rena Ni|LINK
Hi GFrancis,
Do you mean that these pages protected by cookie authentication?
#JWT Combine Cookie Authentication
https://programming.vip/docs/jwt-vs-session-vs-cookie-for-asp.net-core-web-api.html
Best Regards,
Rena
All-Star
58144 Points
15646 Posts
Re: ASP Net Core (2.1) WebApp with API AND secure HTML pages
Nov 18, 2019 08:44 PM|bruce (sqlwork.com)|LINK
with html pages you use cookie authentication. this can be combined with bearer. just add cookie authentication to the project. You can use scheme with the authorize to allow both or just one scheme.