M
M
Mikhail2018-01-31 15:26:19
.NET
Mikhail, 2018-01-31 15:26:19

Why does this code work?

Hello. I deal with user registration in Core MVC on this lesson . Several points are not very clear:
1) Model validation
When describing the Register() method, there is a line:
if(ModelState.IsValid) {...}
As I understand it, this is a field from the inherited Controller class. But how exactly do we check the model for validity if we did not pass it in any of the parameters? How does the class know that it needs to validate the RegisterViewModel from the ViewModels folder?
2) Creating a user
There is a line:

var result = await _userManager.CreateAsync(user, model.Password);

Do I understand correctly that all the logic for hashing, adding salt, etc. is taken over by the creators of Core MVC? It's just that in node.js, this was usually done by hand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-01-31
@mak_ufo

Model Validation
User Creation: Beginning , Continued
ASP.Net MVC is a framework. Those. a complete platform for creating applications - typical actions are out of the box. Similarly, people work in php with laravel, Yii2, etc.
But no one forbids you to fence your bike: change the logic of model checking / algorithms for generating, storing, checking password / authorization logic in principle, the logic of the http request pipeline ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question