I am testing this on chrome. I have set chrome to remember user name and passwords. I have a very simple MVC 5 web application where i have login screen and also screen to create user. When user log in, I let chrome save user name and password.
Problem is that when I try to create new user, its not coming user name as blank, but still showing user name that I logged in with.
I want to do in view and not through controller default vault. I tried using below example link on SO, but my code is still not working
how to set default value HTML.EditorFor()
Here is the code that I tried and its not working.
<div class="form-group">
<div class="col-md-12">
@Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label" })
<br />
@Html.EditorFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control", @Value ="" } })
@Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
</div>
</div>
Please advice what should I do to fix this. You you.
Easiest way around this is to simply change the name of the property in your model from
UserName
toNewUserName
. That way the autofill won't associate autofill entries between the two different fields. Your create and login model are different anyway.Or, you could also try changing the name of the textbox in your View.
You would need to add a parameter in your controller for
NewUserName
next to your other model parameters.