ASP.Net C#如何在通过登录进行身份验证后访问网站上的页面 [英] ASP.Net C# How to make a page on website accessible after authenticating via logon

查看:66
本文介绍了ASP.Net C#如何在通过登录进行身份验证后访问网站上的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个代码,我可以使用它来通过登录对网站进行身份验证后访问网站,这意味着我希望只有用户登录时才能访问它。

任意一个可以帮助我的人。



(NB:我更瘦,还是新手)



提前致谢

I need a code behind that i can use to make a page on a website accessible after authenticating it via logon,meaning i want it to be accessible when the user is logged in only.
Any one who can help me out.

(NB:am a leaner, still a newbie)

Thanks in advance

推荐答案

您必须创建一个Session变量,并在PageLoad事件中检查该Session变量,如果没有,则重定向到登录页面......



如果你想提供访问角色,那么你也可以声明一个roleID并输入Session并检查角色......
You have to make a Session variable and in PageLoad event check for that Session variable and if not get then redirect to login page...

If you want to give access role then you can also declare a roleID and put in to Session and check for role also...


这篇关于ASP.Net C#如何在通过登录进行身份验证后访问网站上的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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