title: How can I get substring of object property in ASP.NET MVC View?
body: <p>I have a view which will display a username. The username is a property of the object the view is strongly typed to.</p>
  
  <p>my username is formatted as such <code>domain\usernametext</code></p>
  
  <p>So i want to get the substring of MyModel.username beginning after the last index of <code>\</code></p>
  
  <p>I tried this but it gives me an invalid operation exception at runtime:</p>
  
  <pre><code>@Html.DisplayFor(x =&gt; x.UserName.Substring(x.UserName.LastIndexOf(@"\") + 1))
  </code></pre>