Introduction
I am going to explain a very popular error i.e Unexpected "if" keyword after "@" character while working with ASP.Net MVC Razor View, I am sharing all aspects of this error Unexpected "if" keyword after "@" character.Error Detail:
Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".When Error "Unexpected "if" keyword after "@" character" comes off
Working on MVC project and working on MVC Razor view, meanwhile a problem faced me whenever using foreach statement in MVC Razor View Engine. I was using nested statement to write some logic. I have been shared my both preview of code 1) Wrong statement and 2) corrected statement which is showing below.
Wrong Statement
@foreach (var item in Model)
{
@if (item.isCorrect)
{
// do something
}
}
Correct Statement
@foreach (var item in Model)
{
if (item.isCorrect)
{
// do something
}
}


Post A Comment:
0 comments: