C#C
C#16mo ago
Denge

.NET Modelstate does not apply validation

Hello, I'm currently developing my first .NET web api/Angular project.

I'm nearly done with it, currently developing the test project but I'm facing a problem with this create function.
I'm trying to test if it throws an error when i leave the name property out (which is required), but my modelstate does not stop it. (Modelstate remains empty)

However, when I test this manually in my front end, the validation does work.

I'm using angular as front end. You can check out my code in the screenshots.
Schermafbeelding_2024-09-12_om_14.14.16.png
Schermafbeelding_2024-09-12_om_14.14.54.png
Schermafbeelding_2024-09-12_om_14.15.12.png
Schermafbeelding_2024-09-12_om_14.15.34.png
Was this page helpful?