Razor doesn't understand unclosed html tags

asp.net-mvc-3, razor

Solution

Try like this:

if (somecondition) {
    @:<div>
}

Problem

With RazorViewEngine, I can do this: ``` if (somecondition) { <div> some stuff </div> } ``` but I can't seem to do this (Razor gets confused): ``` if (somecondition) { <div> } if (someothercondition) { </div> } ``` I have a situation in which I need to put my opening and closing html tags in different code blocks - how can I do this in Razor?

Original source

Related problems