ASP.NET Webアプリケーションで覚えておいてください
-
21-09-2019 - |
質問
ハイみんな、
- ASP.NET Webアプリケーションで私を覚えているオプションを実装する可能性のある方法は何ですか?Alt Text http://www.freeimagehosting.net/uploads/0f9ebba1bb.jpg
解決
フォーム認証を使用している場合は、合格するだけです true
第二の議論として RedirectfromLoginPage.
それ以外の場合、アイデアは本質的に同じです。いわゆるものを作成する必要があります」永続的なクッキー「これは、正しいCookieの有効期限を指定する必要があることを意味します。
他のヒント
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["myCookie"] != null)
{
HttpCookie cookie = Request.Cookies.Get("myCookie");
txtUserName.Text = cookie.Values["username"];
txtPassword.Attributes.Add("value", cookie.Values["password"]);
}
}
}
protected void btnLogin_Click(object sender, EventArgs e)
{
bool IsRemember = chkRememberMe.Checked;
if (IsRemember)
{
myCookie.Values.Add("username", txtUserName.Text);
myCookie.Values.Add("password", txtPassword.Text);
myCookie.Expires = DateTime.Now.AddDays(15);
}
else
{
myCookie.Values.Add("username", string.Empty);
myCookie.Values.Add("password", string.Empty);
myCookie.Expires = DateTime.Now.AddMinutes(5);
}
Response.Cookies.Add(myCookie);
}
ここを見てください: 方法:ASP.NETログインページを作成します
<asp:Login ID="Login1"
runat="server"
DestinationPageUrl="~/MembersHome.aspx">
</asp:Login>
所属していません StackOverflow