Possible breaking change in MVC4 Razor that can be fixed with “@:@”

前端 未结 2 1342
傲寒
傲寒 2020-12-06 16:47

I recently upgraded my website from ASP.NET MVC3 (Razor) to MVC4 (Razor2), and in doing so found what seemed like a breaking change in the Razor view engine.

The sce

相关标签:
2条回答
  • 2020-12-06 17:04

    This is indeed a bug we decided not to fix, note that the syntax is incorrect as there is no transition between C# and markup in this case.

    I understand that resharper shows a warning here but I believe the warning is wrong.

    Here is the bug for future reference https://aspnetwebstack.codeplex.com/workitem/458

    0 讨论(0)
  • 2020-12-06 17:13

    Seems like a bug. It works with String:

    @foreach (var x in Model)
    {
        @String.Format("Foo bar: {0}", x)
    }
    
    0 讨论(0)
提交回复
热议问题