ASP.NET MVC authentication type Windows

56 Views Asked by At

I get the current user account ok and manage to remove the domain charters from the output, please see below:

In my HomeController's Index method:

public ActionResult Index(string username)
{    
    ViewBag.UserName = User.Identity?.Name;
    return View();
}

and from my view

<h3>@ViewBag.username.Remove(0, 7)</h3>

All works fine, removes the domain name and just displays the users name e.g. removes corplt/jsmith to just displays "jsmith" - but can this all be done with in the controller or is it ok to have this code within the view? Any help would be greatly appreciated.

Thanks

John.

0

There are 0 best solutions below