Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No overload for method 'Write' takes 0 arguments

what's wrong with that code ? I'm getting the error from this topic's title.

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

SOLVED, look @ the comments

like image 255
Tony Avatar asked Nov 30 '22 08:11

Tony


1 Answers

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

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

You only use @{ ... } blocks to put code where Razor is expecting markup.

like image 80
SLaks Avatar answered Dec 10 '22 23:12

SLaks