32. Model validation in ASP.NET MVC (Create Actor) | ASP.NET MVC

preview_player
Показать описание
------------------------------------------------------------------
In this part, you will learn about model validation in ASP.NET MVC and for that you will learn how to add data to the database using the ActorsService with Entity Framework.
But, before you add any data to the database you will check if the data is valid, for that you will learn how to validate a model in ASP.NET MVC
===================================
You can also watch my courses on:
===================================
===================================
00:00 - Welcome
00:15 - Adding new ActionResult and updating model requirements
05:05 - Implementing Add method
06:45 - Testing
08:17 - Reload profile picture on model error
09:58 - Thank you
===================================
#modelvalidation #aspnetmvc #csharp
Рекомендации по теме
Комментарии
Автор

The tutorials are great but I don't understand why you sometimes skip crucial parts. For instance, you skipped the part where you had to explain that in order to avoid the actor_movie relationship issue (because of the null value), you need to allow a nullable property in the Actor model: public List<Actor_Movie>? Actors_Movies { get; set; } I love your work but I saw this type of skipped information about 4 times.

kamenpetkov
Автор

to every one the reason why the data didn't post you need to go for model Actors where public List<Actors_Movie>? Actors_Movies { get; set; } you need add ? after < >to make it add null thank me later ^^

gachaGame
Автор

we can pick any image link to add an image on the actors action? or have some rule or something like that?

alisoncharleaux
Автор

Perfect. Thanks a lot. I have subscribed long time ago.

imadabab
Автор

Actor_Movie data coming from view shows invalid and failed ModelState_Valid property, what to do? can not insert record in db

snehalbhirud
Автор

Hello, you are doing a great job man, but i have a problem with creating an actor. I can't create an actor when I press create button. Looks like the problem is in the cookie. The error reads like this: A cookie was not sent to an insecure origin from a secure context. Because this cookie would have been sent across schemes on the same site, it was not sent. This behavior enhances the SameSite attribute’s protection of user data from request forgery by network attackers. I did some research but couldn't figure it out, can you help me?

markobojovic
Автор

When I create an actor nothing happen just the page refreshed and the actor doesn't add to database

marouane
Автор

Thank you for fantastic content, just wonder how many clips you expect this project to have in the end?

ore_bear
Автор

Thank you for the tutorial, it's amazing. I am getting an error not using await with the creat method on Actors controller

infosmart
Автор

in controllers i cant able to add _service.Add(actor) i am getting error please solve

Srinivasan-tlqd
Автор

Hello to everyone!
Since i put [Required]annotations when im going to Actors menu i have sqlNullValueException.
and the error is this :
in ActorsService.cs
+
var result = await

in ActorsController.cs
+
var data = await _service.GetAll();
If i comment the annotations then the page is loading normally.

bentom
Автор

if(!ModelState.IsValid)

I jus add ! In the model state and it worked

name_code
welcome to shbcf.ru