Html.PasswordFor not populated?

I spend a lot of time trying to understand why in razor terms

@HTML.PasswordFor( m => m.Password) 

I cannot set the value from the model, the only solution I found was that he entered the value using html properties such as

 @HTML.PasswordFor( m => m.Password, new { value = Model.Password }) 

Am I doing something wrong? right helper ??? this is a field model configuration

 [Required(ErrorMessage = "La contraseña es obligatoria.")] [StringLength(100, ErrorMessage = "El {0} debe tener al menos {2} caracteres de longitud.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Contraseña")] public string Password { get; set; } 

Is this the only solution?

+4
source share
1 answer

This is a safety feature. To perform this work, it is understood that: a) you can access the user password in plain text and b) transfer it through wiring to your browser.

None of them are safe and should not be encouraged.

As such, this is a feature of Razor, not a problem.

+2
source

Source: https://habr.com/ru/post/1398923/


All Articles