I've very new to C# and I'm using ASP.NET 6.
On a .cshtml Razor page I'm trying to use a ternary operator to fill in a HTML element class based on the very last segment of a URL pathname. So for example: On a page called localhost:7659/Identity/Account/Login I'm trying to test if a loaded URL page name has the word Login in the very last URL segment.
This is what I'm trying at present:
<a class="@Context.Request.Path == '/Login' ? 'active-page' : ''" href="/Identity/Account/Login">
But the above is rendered as
<a class="/Identity/Account/Login == '/Login' ? 'active-page-header-menu-link' : ''" href="/Identity/Account/Login">
ie the code is not being parsed out, also @Context.Request.Path is returning the whole URL pathname, in this case, /Identity/Account/Login how can I just return the value Login?
Thanks