Razor doesn't understand unclosed html tags

前端 未结 4 920
灰色年华
灰色年华 2020-12-04 17:11

With RazorViewEngine, I can do this:

if (somecondition) {
     
some stuff
}

but I can\'t seem to do this (Razor ge

4条回答
  •  [愿得一人]
    2020-12-04 18:02

    To explain Darin's answer, i.e prefixing the HTML like this:

    @:
    

    @: in Razor means 'render something as plain text'

    or you can use this, which outputs the HTML as you orginally wrote it (this can also be used to avoid the automatic HTML encoding that Razor does if you're trying to output HTML):

    @Html.Raw("")
    

    (Html.Raw reference from MS - http://msdn.microsoft.com/en-us/library/gg568896(v=vs.111).aspx)

提交回复
热议问题