locked
Visual Studio reporting "Invalid token 'Text' at root level of document" errors on non-xml document. RRS feed

  • Question

  • The document in question is a NodeJs view template using the Vash view engine.
    It's named index.vash, it's build action is 'Content' and it's contents are:-

    @html.extend('layout', function(model) {
      @html.block('body', function(model) {
      <div>
        <h1>@model.title</h1>
        <p>Dummy text</p>
       </div>
      })
    })

    VS2017 is whining bitterly at the first two lines.
    Why is VS assuming this is an html file? Surely it hasn't inferred html from the content?
    Sunday, August 27, 2017 10:22 AM

All replies

  • Update: If I wrap the template in a <div>, the problem goes away:-

    <div>@html.extend('layout', function(model) {
      @html.block('body', function(model) {
      <div>
        <h1>@model.title</h1>
        <p>Dummy text</p>
       </div>
      })
    })
    </div>

    So perhaps it makes sense, perhaps having the Vash directives at the root level is invalid.
    But as the file runs OK despite the whinings of VS, it looks more likely that VS is being overly critical.
    Sunday, August 27, 2017 10:34 AM
  • Hi petert1401,

    This is Visual C# forum. As your issue is related to web please refer to ASP.Net forum for getting response. Hope this helps you.

    https://forums.asp.net/


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Sunday, August 27, 2017 7:34 PM