asp.net-mvcrazorcompiler-warningspragma

Using #pragma statement in Razor View


We have some files with the jQuery vsDoc includes like this for syntax help;

@if (false)
{
    <script src="@Url.Content("~/Scripts/jquery.validate-vsdoc.js")" type="text/javascript"></script>
}

And it generates some annoying compiler warnings about unreachable code, I would like to wrap that statement with a #prama warning but I cant figure out the syntax in Razor.


Solution

  • @{ #pragma warning disable } 
    @if (false)
    {
        <script src="@Url.Content("~/Scripts/jquery.validate-vsdoc.js")" type="text/javascript"> </script>
    }
    @{ #pragma warning restore }
    

    Works for me