登录页面和根据用户类型重定向页面 [英] Login Page & Redirect the page as per usertype

查看:75
本文介绍了登录页面和根据用户类型重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建NewUser表和登录页面.

我有登录"页面,在该登录页面中1)UserName(txtbox1),2)Password(txtbox2),3)DropDownList(Admin/Executive)和登录"按钮中的UserType.

当我单击Login Btn时,它将按照数据库(NewUser Tbl)检查用户名,pass,usertyper(如果我选择"Admin"),并在Admin(Folder)---> Home.aspx(Its Belog)中重定向页面到母版页"),如果我选择执行"检查用户名和密码,并将页面重定向到Executive(文件夹)---> Home.aspx,则执行类似,否则会给出无效的密码和用户名. asp.net 4.0的plz解决方案

I am create NewUser Table, and Login Page.

I have Login page, in that login page 1)UserName(txtbox1),2)Password(txtbox2),3)UserType In DropDownList(Admin/Executive) & Login Button.

When I click Login Btn , it will check username,pass,usertyper( if I chooes "Admin")so as per DB (NewUser Tbl) and redirect the page in Admin(Folder)--->Home.aspx(Its Belog to Master Page), similar for Execute if i chooes "Executive" check username & pass and page redirect to Executive(Folder)--->Home.aspx other wise give invalid pass & username. plz solustion as per asp.net 4.0

推荐答案



您可以编写如下代码.

Hi,

You can write code as below.

string usreType = DropDownList.SelectedItem.Value;

//Validate and authenticate user 
bool IsValidUser = //validate user form db with user name, password and user type
if(IsValidUser)
{
   switch(userType)
   {
     case : "Admin" //Redirect user to Admin folder
     break;
     case : "Executive " //Redirect user to Executive folder
     break;
   }
}
else
{
   //show error message as not valid user
}



实施此senario的最佳方法是首先使用用户名和密码验证用户.然后使用用户名和密码验证用户类型.通过使用这种技术,您可以显示更适当的错误消息.



The best way to implement this senario is to first validate user with user name and password. And then validate type of user with user name and password. By using this technique you can display more appropriate error message.


您可以执行以下操作...


如您在登录页面上所说,您有两个文本框和一个下拉菜单供您选择用户类型.

因此,如果用户从下拉列表中选择管理员"并输入用户名和密码,并且登录成功,则可以将其重定向到Admin \ Home.aspx,或者如果他/她无法通过用户名/密码成功进行身份验证,则拒绝登录并留在您的登录页面上.对Executive执行相同操作,然后重定向到Executive \ Home.aspx
you can do something like this...


as you say on your login page you have two text boxes and one drop-down for selection of user type.

so if user select Admin from drop-down and enter his user name and password and if it will successfully login then you can redirect him to Admin\Home.aspx or if he/she will not successfully authenticated by username/password then refuse to login and stay on your login page. do same thing for Executive and redirect to Executive\Home.aspx


这篇关于登录页面和根据用户类型重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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