I have code like these:
<div role="alert">
<div >
<a>Dear, </a>
@foreach (var item in User.Claims.Take(2))
{<a>@item.Value</a>}
<a>. Welcome. </a>
</div>
and it's output like:
Dear, < MRTGD > < [email protected] >. Welcome.
I get the username and e-mail address from the active directory. Unfortunately, i cant get display name from active directory so i want to get display name from e-mail adress. But i cant use substring function on object.
I need a sample result like these:
Dear, NAME SURNAME. Welcome.
Do you have any suggestions?
CodePudding user response:
Well if the email is always in the expected format you could use:
string[] tokens = item.Value.Split('@').First().Split('.');
string name = tokens.First();
string surName = tokens.Last();