安全登录或登录检查在asp.net [英] Secure Login Or Login check in asp.net
问题描述
我是ASP的新手,在这里,我的问题是我有一个主页,简介,联系方式和login
网页.在此网站上,用户可以login
然后访问主页,主页上有带有母版页的网格视图.问题是用户可以在没有login
的情况下访问主页,只需在地址栏中编辑路径即可.例如
login
页面路径为
I am new in asp, here my question is that i have a website with pages home, about, contact, and login
. In this website user can login
and then access the home page, on home page there is a grid view with master page. The problem is that user can access the home page without login
, just edit the path in address bar. For example
the login
page path is
http://lolhost:54515/mastergridvie/Login.aspx
然后用户对其进行编辑
http://localhost:54515/mastergridvie/Home.aspx
这样用户无需登录即可进入主页,我该如何防止呢?
so user can go on home page without login, How I can prevent this?
我知道为此使用会话,但是我不知道如何以及在何处为此创建会话:( 请任何人能帮助我吗?
I know for this there use a session, but I have no idea how to and where create a session for this :( Please can anyone help me?
推荐答案
在登录页面中像这样创建会话.
Create Session in login page like this.
Session["userid"]="something";
然后检查每个这样的页面加载.
And After That Check in Every Page Load like This.
if(Session["userid"] == null)
{
Response.Redirect("Login.aspx");
}
这篇关于安全登录或登录检查在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!