Asp.Net Core 3.1 Razor Error: CS1003: Syntax error, ',' expected


Question: How do you solve Asp.Net Core Razor Error  CS1003: Syntax error, ',' expected?


Login to See the Rest of the Answer

Answer:
Look carefully where it shows the line numbers that is where you need to start looking: ".cshtml(112,152,112,160): error CS1003: Syntax error, ',' expected"
- In the case above, starting looking from line 112 up to 160 for clues.

  • The error should be in the directive where the code is not expected to be. See image below:

                                    <div class="form-group">
                                        <label asp-for="PropertyName" class="control-label">TextInHere</label>
                                          @*Below is where the error is coming from, did you notice that "disabled" is in a wrong directive?*@
                                        <input asp-for="PropertyName disabled" value="@Model.Value" class="form-control" /> 
                                        <input asp-for="PropertyName" hidden value="TextValue" class="form-control" />
                                    </div>?
  • The first Input HTML tag is where the error is coming from, did you notice that "disabled" is in a wrong directive?
  • Sometimes Visual Studio 2019 does not highlight the error in Razor Pages, paying attention to the error log helps tremendously.






For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]