Html.PasswordFor不填充? [英] Html.PasswordFor is not populated?

查看:922
本文介绍了Html.PasswordFor不填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了我很多时间,试图理解为什么在

I spend a lot of my time, trying to understand why in a razor expression of

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

我无法设置从模型的唯一解决方案的值我发现它是通过注射这样的HTML属性值

I can't set the value from the model the only solution that I found it's injecting the value by html properties like this

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

我是不是做错了什么?是正确的帮手?这是该领域车型的配置

Am I doing something wrong?? is the correct helper?? this is the 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; }



这是唯一的解决办法?

It's the only solution?

推荐答案

这是一个安全功能。为了使这项工作意味着一个),你可以在纯文本访问用户密码和b)通过线路进入他们的浏览器传送信号。

It's a security feature. To make this work implies that a) you are able to access the users password in plain text and b) are transmitting it over the wire to their browser.

既不的是安全的,不应该鼓励

Neither of which are safe and shouldn't be encouraged.

因此,这是剃刀的一个特征,而不是一个问题。

As such, this is a feature of Razor, rather than an issue.

这篇关于Html.PasswordFor不填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆