我认为这种情况:
@if (User.Identity.Name == "abc")
{
... do this!
}
Run Code Online (Sandbox Code Playgroud)
如何在View(在MVC中)中拆分此字符串“ User.Identity.Name”,以便创建新条件,如下所示:
string last = User.Identity.Name.Substring(User.Identity.Name.LastIndexOf('.') + 1);
if (last == "this")
{
... do this!
}
Run Code Online (Sandbox Code Playgroud)
谢谢。