@{ ViewBag.Username = \"Charlie Brown\"; string title1 = string.Format(\"Welcome {0}\", ViewBag.Username); var title2 = string.Format(\"Welcome {0}\", Vi
It's the view bag which is dynamic.
If you use actual username (instead of ViewBag.UserName)it would work. Or cast (string)ViewBag.Username into string.
(string)ViewBag.Username