Handling quotes in Blazor

Viewed 1033

I've got a line like this in my Blazor Web Assembly app:

<Calendar User="@context.User.Claims.Where(user => user.Type == "sid")"></Calendar>

But VS doesn't like the fact that "sid" is in quotes because it messes up the User="" attribute. How do I handle this?

Also, side question, is this the proper way to get a user Id in blazor web assembly? This seems like the easiest way, but I'm new to authentication so I don't know if I'm violating a best practice by doing this.

Thanks!

2 Answers

You can use parenthesis @( ) to make it a code block

<Calendar User="@(context.User.Claims.Where(user => user.Type == "sid"))" />
Related