3

I have this markup:

@using (Html.BeginRouteForm("Default", new { controller = "Home", action = "Form" }, FormMethod.Post, new { @ID="FormId", @Name="FormId"}))
{
    <span>...</span>
    <div class="clearFloats"><!-- ---></div>
    <span>...</span>
}

And since moving to Razor 2, MVC 4 I now get the error:

  • The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.

If I remove the <div class="clearFloats"><!-- ---></div> code, everything is OK. I know the solution is to change these float clearing divs for a different construct of somesort, but why is it now breaking?

5
  • Is it happening only in MVC4 ? worked fine in MVC3 Commented Aug 21, 2012 at 13:14
  • 3
    Looks like a bug in WebPages v2 to me. Commented Aug 21, 2012 at 13:15
  • What is the content of those spans? Can't see why that would matter given what you said fixes the issue but it possibly contributes.. Commented Aug 21, 2012 at 13:17
  • @Shyju Yup, it compiled fine in MVC3 Commented Aug 21, 2012 at 14:01
  • @SimonWhitehead It varies from page to page (TBH, mostly no spans... That was the simplest breaking example I could come up with to illustrate the query). Commented Aug 21, 2012 at 14:03

1 Answer 1

4

A temporary solution would be to wrap the <!-- --> with @Html.Raw("<!-- -->") which seems to eliminate the error.

Edit: Actually the problem in your example is is the trailing three dashes ---> on the close comment tag. Remove one of those and it works correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.