No overload for the 'Write' method takes 0 arguments

what is wrong with this code? I get an error message from this section.

@{ var errors = ViewData.ModelState.Values.Where(x=>x.Errors.Count > 0).ToList();} 

SOLVED , see @ comments

+4
source share
1 answer

Inside a using statement or other code block, Razor expects code, not markup.
Therefore, you must enter the code directly, not in @{ ... } .

The Razor parser interprets your code as @ (prints an empty expression), followed by a normal block of C # statements ( { ... } ).

You only use @{ ... } blocks to place code where Razor expects markup.

+20
source

Source: https://habr.com/ru/post/1343359/


All Articles