I am trying to print a string in Razor using the following code:
@Html.Raw("Welcome @(ViewBag.Content.User.Name)!")
The output of this string is unfortunately: "Welcome @(ViewBag.Content.User.Name)!". But when I print it this way:
@Html.Raw("Welcome " + @(ViewBag.Content.User.Name) + "!")
The output of the string is: "Welcome Yanick!", just what I want but I don't want to print it this way. Is there a possibility to run the Razor code that is inside a string (see first example)? I tryed also Html.Encode() but this didn't work either...