只有身份验证用户才能访问经过身份验证的页面,否则将重定向到使用ASP.NET webfroms的登录页面 [英] Only authenticate user can access the authenticated page otherwise redirect to login page uaing ASP.NET webfroms

查看:80
本文介绍了只有身份验证用户才能访问经过身份验证的页面,否则将重定向到使用ASP.NET webfroms的登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个职位门户项目,我有4个模块,比如guestuser,jobseeker,Employer和admin。



guestuser只能访问默认网页但是没有验证网页,如果假设guestuser想要​​访问求职者的主页,它将重定向到登录页面。



我试过web.config但是它没有用?



任何人为此提供解决方案?

I am doing one job portal project in that i ahve 4 modules are there like guestuser,jobseeker,Employer and admin.

guestuser can access only default webpages but not authenticate webpage,if suppose guestuser wants to access the jobseeker's home page it will redirect to the login page.

I tried web.config but its not working?

Anyone give solution for this?

推荐答案

如果您使用成员 [ ^ ]然后很简单:服务器将为您处理所有这些。



如果你不是,那么你应该是!
If you are using Membership[^] then it's simple: the server will handle all that for you.

If you aren't, then you should be!


你好
U存储管理员用户在表中,所以在管理页面加载事件时你得到详细信息表格并检查用户是否是管理员,如果没有,则重定向到登录pa ge,对于页面加载事件,你需要在会​​话变量中获取用户名,该会话变量你必须在登录时添加,所以admin表中的用户名允许其他明智的重定向到登录页面。



查看此链接



[ ^ click ]


1)在数据库中创建一个角色表Role并插入你在这里提到的所有角色。

2)将一个角色映射到用户表中的每个用户。

3)在登录期间获取roleId以及用户表和存储在会话中所需的其他详细信息。

4)在Pageload上检查存储在会话中的roleid



ex:if(RoleID ==1)

{

//做一些操作

}

其他

{

//将用户重定向到某个无法访问的页面消息

}





我希望这会对你有所帮助。



谢谢
1) create a role table "Role" in the database & Insert all the roles u have mentioned here.
2) Map one role to each user in user table.
3) during the sign-in get the roleId along with the other details you need from user table and store in the session.
4) On Pageload check with the roleid stored in the session

ex: if(RoleID == "1")
{
//Do Some Operation
}
else
{
//Redirect user to some page with "No Access" Message
}


I hope this will be helpful for you.

Thanks


这篇关于只有身份验证用户才能访问经过身份验证的页面,否则将重定向到使用ASP.NET webfroms的登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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