Assuming Razor syntax, you can achieve this with.
@{string pageMessage = ViewBag.Message.ToString();}
then pageMessage is a local variable available for the page, for example:
<h1>@pageMessage</h1>
EDIT
The ViewBag is a dynamic object that is a member of the Controller base class, so just specify this once in the entire controller, you can put something in your controller constructor.
public class MyController : Controller { public MyController() { ViewBag.ViewTime = DateTime.Now.ToString(); }
AlexC source share