# What is Blazor? A Tutorial on Building Web Apps with Authentication

**URL:** <https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611>\
**Category:** Get Help\
**Tags:** dotnet, net-core, aspnet-core, .net, blazor\
**Created:** [November 11, 2019, 2:56pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611 "2019-11-11T14:56:06Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![JohnMarsing](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johnmarsing/32/8280_2.png) [@JohnMarsing](https://community.auth0.com/u/JohnMarsing)\
**Post date:** [January 4, 2020, 6:27pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/21 "2020-01-04T18:27:47Z")

</div>

I just converted my Azure [ASP.Net](http://ASP.Net) Web App that uses Auth0 to razor page 3.0 and I’m having troubles with login in. The error I’m getting after I get the Auth0 dialog log is that it can’t find the **signin-auth0** url (this used to work). I think my problem is with the end point (I know things have changed in the startup class regarding this). Is there an example that deals with Razor Pages using core 3.0 or 3.1? I definitely want to get to Blazor Server side but want to get the Razor Pages web app working correctly with Auth0 first.  
Thanks  
John

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [January 7, 2020, 10:50am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/22 "2020-01-07T10:50:46Z")

</div>

The OpenID configuration in the `Startup` class is basically the one you find in the article. There shouldn’t be any relevant changes for Razor.  
Maybe you have double-checked it, but this seems the typical case when the **Allowed Callback** URL doesn’t exactly match the `callbackPath` you defined in the OpenID configuration options.  
Please, ensure that the **signin-auth0** URL in the Auth0 dashboard matches the configured URL, including the protocol scheme and the trailing slash.

---

<div class="post-metadata">

**Author:** ![steamonimo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/steamonimo/32/17169_2.png) [@steamonimo](https://community.auth0.com/u/steamonimo)\
**Post date:** [January 10, 2020, 3:27pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/23 "2020-01-10T15:27:42Z")

</div>

Hello Andrea,

I would like to suggest that you integrate the adjustmens to the Logout method into this blog post as well. Just by following this discussion I found out the reason why the Logout does not work as expected.

Could you please eloborate how the current Auth0 User can be accessed in blazor pages? Currently the object @context.User.Identity.Name seems to be empty. I would like to show the Name of the user or I would like to add additional claims / roles to the current user object from within my application (roles with finer granularity than Auth0 can provide).

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 13, 2020, 8:08am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/24 "2020-01-13T08:08:31Z")

</div>

Hey there @steamonimo I’m sure @andrea.chiarelli will followup on this once he’s online!

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [January 14, 2020, 4:40pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/25 "2020-01-14T16:40:49Z")

</div>

Hi @steamonimo,  
We’ve just updated the blog post with the logout fixes.

Regarding your request about user data, unfortunately, `User.Identity` is not automatically populated with the user profile’s data. To enable it, you should apply some changes to OpenID Connect settings in the `Startup.cs` file.  
You have to add `using Microsoft.IdentityModel.Tokens;` in the using section. Then, you need to adjust the OpenID connect options as follows:

```csharp
  .AddOpenIdConnect("Auth0", options =>
  {
    //... other options

    // Configure the scope
    options.Scope.Clear();
    options.Scope.Add("openid");
    // new stuff
    options.Scope.Add("profile");

    options.TokenValidationParameters = new TokenValidationParameters
      {
          NameClaimType = "name"
      };
    // end new stuff

    //... other options
  };

```

The newly added options are the `profile` scope, which requests the server for the user’s profile’s data, and the `TokenValidationParameters`, which indicates how to map the OpenID claims to `User.Identity` properties.  
There are historical reasons behind this. If you want to know more, read [this](https://leastprivilege.com/2016/08/21/why-does-my-authorize-attribute-not-work/).

---

<div class="post-metadata">

**Author:** ![steamonimo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/steamonimo/32/17169_2.png) [@steamonimo](https://community.auth0.com/u/steamonimo)\
**Post date:** [January 14, 2020, 8:42pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/26 "2020-01-14T20:42:06Z")

</div>

Thanks for your reply! Now the user can be retrieved via “context.User.Identity.Name”.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 15, 2020, 9:02am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/27 "2020-01-15T09:02:16Z")

</div>

Glad it’s working for you now!

---

<div class="post-metadata">

**Author:** ![mitch.barker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mitch.barker/32/12765_2.png) [@mitch.barker](https://community.auth0.com/u/mitch.barker)\
**Post date:** [January 30, 2020, 3:38pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/28 "2020-01-30T15:38:13Z")

</div>

We’re looking to move our app development from C#/WPF to Blazor. So I’m new to Blazor and Auth0. This seemed like a good tutorial to try, because authentication is obviously important.  
I downloaded the project from GitHub. I created an Auth0 account and updated the field in appsettings.json accordingly. When I click the login button I get this error:  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/2/32269acdfbff1dd28268f2b0050f239ef0957f5d.png)

The output log from VS is:

```
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/2.0 GET https://localhost:44363/login?redirectUri=/  
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executing endpoint '/Login'

```

Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Route matched with {page = “/Login”}. Executing page /Login  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executing handler method QuizManager.Pages.LoginModel.OnGet - ModelState is Valid  
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler: Information: AuthenticationScheme: Auth0 was challenged.  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executed handler method OnGet, returned result .  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executing an implicit handler method - ModelState is Valid  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executed page /Login in 1164.6662ms  
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint ‘/Login’  
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 1193.562ms 302 text/html; charset=utf-8  
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/2.0 POST [https://localhost:44363/\_blazor/disconnect](https://localhost:44363/_blazor/disconnect) multipart/form-data; boundary=----WebKitFormBoundary30cUVlzBJhzlwgTE 359  
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executing endpoint ‘Blazor disconnect’  
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint ‘/\_blazor’  
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 10583.7001ms 101

I also verified in the dashboard that  
Allowed callback URL is: [https://localhost:5001/callback](https://localhost:5001/callback)  
Allowed logout URL is: [https://localhost:5001/](https://localhost:5001/)

This is my first adventure with authorization, so any help is appreciated.

Mitch

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [January 30, 2020, 5:10pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/30 "2020-01-30T17:10:13Z")

</div>

Hi @mitch.barker,  
Thank you for joining Auth0 Community!  
At a very first look, it seems that you are running your application at this base URL [https://localhost:44363](https://localhost:44363) but you registered the allowed callbacks and logout URLs with [https://localhost:5001](https://localhost:5001)  
They should match.

---

<div class="post-metadata">

**Author:** ![mjones](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mjones/32/12764_2.png) [@mjones](https://community.auth0.com/u/mjones)\
**Post date:** [March 16, 2020, 12:28am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/31 "2020-03-16T00:28:43Z")

</div>

Could you provide an example of securing an [ASP.Net](http://ASP.Net) Core hosted WebAssembly app with Auth0?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 16, 2020, 7:55am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/32 "2020-03-16T07:55:35Z")

</div>

Hey there @mjones let’s wait for Andrea to be online to share more on that front 🙂

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [March 16, 2020, 8:52am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/33 "2020-03-16T08:52:30Z")

</div>

Hi @mjones,  
Currently, Blazor WebAssembly is in beta/preview release and [a few issues](https://github.com/dotnet/aspnetcore/labels/blazor-wasm) affect it also on the authentication and authorization side. The official release should be [delivered on May](https://github.com/dotnet/aspnetcore/milestone/58).  
Until then, we are not planning to publish any examples based on a non-stable version of the product.  
Thanks anyway for your interest. I will let you know when we will publish an accurate and stable Blazor WASM example with Auth0 integration.

---

<div class="post-metadata">

**Author:** ![Dmo16](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmo16/32/17990_2.png) [@Dmo16](https://community.auth0.com/u/Dmo16)\
**Post date:** [March 16, 2020, 8:26pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/34 "2020-03-16T20:26:34Z")

</div>

This is going to sound super silly and I apologize but, this did fix the “name” issue for me, however, how do I access _the rest_ of the profile information?

I see that we added the “profile” scope, but I’m unable to access any of it using the @context modifier.

If this is a MS thing and not an Auth0 thing, please point me in the right direction to unscramble my mind 😃

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [March 17, 2020, 10:01am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/35 "2020-03-17T10:01:32Z")

</div>

Hi @Dmo16,  
This is definitely a Microsoft issue. It is documented in this [blog post](https://leastprivilege.com/2016/08/21/why-does-my-authorize-attribute-not-work/).  
In a nutshell, you should map claims manually by using `TokenValidationParameters` and/or `ClaimActions`.  
I hope that [this document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/additional-claims?view=aspnetcore-3.1) may give you some directions to solve this problem.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 17, 2020, 10:47am UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/36 "2020-03-17T10:47:47Z")

</div>

If you have any further questions feel free to reach out!

---

<div class="post-metadata">

**Author:** ![Dmo16](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmo16/32/17990_2.png) [@Dmo16](https://community.auth0.com/u/Dmo16)\
**Post date:** [March 17, 2020, 2:02pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/37 "2020-03-17T14:02:29Z")

</div>

Thanks Andrea!

Both of those bits of information helped greatly.

I was able to sort out my issue.

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [March 17, 2020, 2:28pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/38 "2020-03-17T14:28:44Z")

</div>

Happy to hear this! 🙂

---

<div class="post-metadata">

**Author:** ![arren.vandosselaer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arren.vandosselaer/32/12742_2.png) [@arren.vandosselaer](https://community.auth0.com/u/arren.vandosselaer)\
**Post date:** [March 19, 2020, 4:36pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/39 "2020-03-19T16:36:51Z")

</div>

Hi.

I’m trying role-based access on the blazor front-end. I’m using attribute to show content only to an admin.

![](https://global.discourse-cdn.com/auth0/original/3X/8/2/8278f2797dba9120d1ba5093bb0c13a6f78bdc69.png)

This is the code I use. Im signed in with an account with the admin role. But it doesn’t show anything. Am i supposed to add roles in the startup where openID is configured?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![andrea.chiarelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andrea.chiarelli/32/16034_2.png) [@andrea.chiarelli](https://community.auth0.com/u/andrea.chiarelli)\
**Post date:** [March 23, 2020, 3:04pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/40 "2020-03-23T15:04:30Z")

</div>

Hi @arren.vandosselaer,  
To leverage role-based access you need to configure roles on the Auth0 side and configure OpenId accordingly. I provide you with a few links to Microsoft and Auth0 documentation:

- [Microsoft doc on Authorization and Blazor](https://docs.microsoft.com/en-us/aspnet/core/security/blazor/?view=aspnetcore-3.1&tabs=visual-studio#authorization)
- [Auth0 and ASP.NET Core Authorization docs](https://auth0.com/docs/quickstart/webapp/aspnet-core-3/03-authorization)

I hope this can be useful as a starting point.

---

<div class="post-metadata">

**Author:** ![arren.vandosselaer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arren.vandosselaer/32/12742_2.png) [@arren.vandosselaer](https://community.auth0.com/u/arren.vandosselaer)\
**Post date:** [March 27, 2020, 12:57pm UTC](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/41 "2020-03-27T12:57:54Z")

</div>

Thanks for the answer. I found out what the issue was. I had to create an auth0 rule with javascript that added the roles to the identity claims!

I am adding an image down below incase it might help someone else stuck on this.

 ![](https://global.discourse-cdn.com/auth0/original/3X/2/a/2a6bae1511da0963251a86ec2ca5c8ddeb40f0e1.png)

[Previous page](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611.md?page=1)

[Next page](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611.md?page=3)
