Ive got a mega annoying problem I have a view with:
@{
if(ViewBag.Section == \"Home\")
{
The simplest way to write this would be:
Or, if you prefer, you can use a local variable:
@{ var headerID = ViewBag.Section == "Home" ? "headerFrontPage" : "header"; }
Regarding the more general case of unclosed tags in Razor code blocks, you can explicitly mark the opening tag as content:
@if (ViewBag.Section == "Home")
{
@:
- 热议问题