管理者を認証するためにweb.configファイルのcredentialタグを使用しました。管理者がユーザー名とパスワードを変更するためのフォームを含むページを作成する方法はありますか?これはweb.configの私のコードです:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<sessionState cookieless="AutoDetect" mode="InProc" timeout="114400">
</sessionState>
<authentication mode="Forms">
<forms timeout="1440" loginUrl="~/entrance_before_paying.aspx" defaultUrl="Admin/Default.aspx" name=".ASPXFORMSDEMO" cookieless="AutoDetect" protection="All">
<credentials passwordFormat="Clear">
<user name="elmiragolshanff@yahoo.com" password="elmira" />
</credentials>
</forms>
</authentication>
</system.web>
サインインページでこのコードを使用して、ユーザーが管理者であるかどうかを確認しました。
private void enter()
{
if (FormsAuthentication.Authenticate(TextBox1.Text.Trim(), TextBox2.Text.Trim()))
{
FormsAuthentication.RedirectFromLoginPage("admin user name in credential tag", true);
}
else
{
// enter as a user}
}
}