如何从浏览器中清除记住的用户名和密码 [英] How to clear remembered usename and password from browser

查看:350
本文介绍了如何从浏览器中清除记住的用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何技术可以清除浏览器中记住的用户名和密码?



在MVC3中



1我已登录并从mozilla firfox浏览器中选择选项记住用户名和密码



2限制页面完成功能后我终于退出



3当我打开我的登录窗口时自动显示我的用户名和密码

对于那种情况我该如何删除它们?



请帮帮我。

解决方案


MVC没有普通旧ASP的服务器控件。净。因此,您的控件上没有进行任何服务器处理。它们将完全按照您键入的方式呈现给客户端。主题不是你将在MVC中使用的东西,因为它们适用于ASP.NET服务器控件,你不会在这里使用它们。也就是说,HTML渲染器在渲染视图时会被服务器处理。你需要使用html属性重载将autocomplete =off添加到实际的HTML控件中。



@ Html.TextBoxFor(x => x.Something, new {autocomplete =off})

或者在asp.net服务器控件中设置autocomplete =off时呈现的实际HTML属性。



编辑:影响所有文本框的一个选项是创建自己的Html辅助方法。只需创建一个扩展方法就像这样:



使用System.Web.Mvc;

使用System.Web.Mvc.Html;



public static MvcHtmlString NoAutoCompleteTextBoxFor< tmodel,>(此HtmlHelper< tmodel> html,Expression< func>< tmodel,>>表达式)

{

返回html.TextBoxFor(表达式,新{autocomplete =off});

}


< pre lang =cs> Html.BeginForm(
action,controller,FormMethod.Post, new {autocomplete = off})


Is there any technique to clear remembered username and password from browser?

In MVC3

1 I have login and select option from mozilla firfox browser " remember username and password "

2 After complete functionality in restricted pages finally i have logout

3 when i re open my login window that show my username and password automatically
for that situation how can i remove those?

Please help me.

解决方案


MVC does not have server controls like plain old ASP.NET. Therefore no server processing is done on your controls. They are rendered to the client exactly how you type them. Themes are not something you will use in MVC, because they apply to ASP.NET server controls and you won't be using those here. That said, HTML helpers do get processed by the server as the view is rendered. You will need to add autocomplete="off" to the actual HTML control using the html properties overload.

@Html.TextBoxFor(x => x.Something, new { autocomplete="off" } )
Or whatever the actual HTML attribute is that gets rendered when you set autocomplete="off" in the asp.net server control.

EDIT: One option to affect all text boxes would be to create your own Html helper method. Just create an extension method Like this:

using System.Web.Mvc;
using System.Web.Mvc.Html;

public static MvcHtmlString NoAutoCompleteTextBoxFor<tmodel,>(this HtmlHelper<tmodel> html, Expression<func><tmodel,>> expression)
{
return html.TextBoxFor(expression, new { autocomplete="off" });
}


Html.BeginForm(
    action, controller, FormMethod.Post, new {autocomplete="off"})


这篇关于如何从浏览器中清除记住的用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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