Reputation: 15091
I can render ViewBag.Message
in a Razor view as follows.
<h1>Message: @{string message = ViewBag.Message?? "Empty";} @message</h1>
Is there any shorter way to do so without using a temporary variable message
?
Upvotes: 0
Views: 21
Reputation: 10320
Try using an explicit expression with parenthesis:
<h1>Message: @(ViewBag.Message ?? "Empty")</h1>
Upvotes: 1