The razor is really trying to understand your HTML. Unfortunately, it cannot be very intelligent and recognize dynamic code or code outside of an expression.
WITH
</div> <div>
is invalid HTML, it complains.
You can avoid this problem by using @:
This forces the razor to bypass its "HTML recognition" and simply print whatever you ask.
eg.
@if (Team.Id == ViewBag.TeamId) { @:</div> @:<div class="row"> @: }
source share