【发布时间】:2014-07-29 16:08:58
【问题描述】:
在我看来,我有这种情况:
@if (User.Identity.Name == "abc")
{
... do this!
}
如何在视图(在 MVC 中)中拆分此字符串“User.Identity.Name”,以便创建新条件,如下所示:
string last = User.Identity.Name.Substring(User.Identity.Name.LastIndexOf('.') + 1);
if (last == "this")
{
... do this!
}
谢谢。
【问题讨论】:
-
你可以使用
Split("some string")分割它 -
我需要找到点“。”和字符串的最后一个索引,所以我需要在点之后找到字符串
标签: asp.net-mvc string model-view-controller view split