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?

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.
Asp.Net Core Razor Error error CS1003 Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue


© 2021 - ErnesTech - Privacy