如何为管理员创建登录 [英] how to create a login for administrator
本文介绍了如何为管理员创建登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个登录控件可以帮助用户登录,问题是我希望管理员也使用相同的登录控件登录并被重定向到不同的页面..我有什么方法可以做到这一点?
谢谢:D
I've got this login control which helps the users to login, The problem is that I want the admin also to use the same login control to login and be redirected toa different page..Is there any way i can do that?
Thank you :D
推荐答案
在列名为UserType的用户表中添加一列。保存A/U之类的值。
其中A - 管理员用户
U - 普通用户
现在用户登录时,添加支票UserType like
Add a column to user table with column Name 'UserType'. Save values like 'A'/'U'.
where A - Admin User
U - Normal User
Now when user login, add a check on UserType like
if(UserType == "A")
{
response.redirect("Admin Page Url");
}
else
{
response.redirect("User Page Url");
}
我明白了,谢谢你:),实际上我正在使用asp.net C#的内置登录控件所以我有创建角色使其在两个不同的场景中工作用户和管理员。我放置了一个链接按钮,只有在管理员登录时才能看到它,将他重定向到管理页面。
I got it,Thank you anyways :),well actually i was using the inbuilt login control of asp.net C# so i had to create roles to make it work in 2 different scenarios the user and admin.I placed a linkbutton and made it visible only at admins login to redirect him to admin page.
protected void Page_Load(object sender, EventArgs e)
{
if (User.IsInRole("admin"))
{
LinkButton3.Visible = true;
}
else
{
LinkButton3.Visible = false;
}
}
参考
没有登录控制
http://www.aspdotnet-suresh.com/2011/12/how-to -create-simple-login-form-using.html [ ^ ]
或
带登录控制
http://www.aspdotnet-suresh.com/2012/01/aspnet-login-control-to-check- user.html [ ^ ]
btn上的
点击
if(txtusername.text ==admin)
{
response.redirect(〜/ admin.aspx);
}
else
{
response.redirect(〜/ user.aspx);
}
Refer
without login control
http://www.aspdotnet-suresh.com/2011/12/how-to-create-simple-login-form-using.html[^]
or
with login control
http://www.aspdotnet-suresh.com/2012/01/aspnet-login-control-to-check-user.html[^]
on btn Click
if(txtusername.text == "admin")
{
response.redirect("~/admin.aspx");
}
else
{
response.redirect("~/user.aspx");
}
这篇关于如何为管理员创建登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文