为什么它不限制我的代码中的直接URL访问? [英] why it is not restricting direct url access in my code?

查看:97
本文介绍了为什么它不限制我的代码中的直接URL访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请纠正我...所以基本上我已经实现了一个代码,我已经使用会话变量现在成功登录用户可以通过页面访问但是aftr会话过期它应该再次重定向到登录页面,同时应该防止直接url access..how to this?

please correct me...so basically i had implemented one code where i have used session variable now on successful login user can access through pages but aftr session expired it should again redirect to login page and at same time should prevent direct url access..how to do this?

推荐答案

在每个页面加载时,检查会话是否为空并执行相应的操作。

类似的东西,

On every page load, check if session is null or not and do the appropriate action.
Something like,
protected void somepage_load(... ...)
{
    if(Session["UserSession"] == null)
    {
        Response.Redirect("~/login.aspx");
    }
    else
    {
        // load the page
    }
}





- KR



-KR


使用Global .asax文件检查会话。



以下链接对您有用尝试此

http:// www .c-sharpcorner.com / UploadFile / 0c1bb2 / redirect-page-after-session-time-in-Asp-Net424 / [ ^ ]
Use Global .asax file to check session.

Below link will be useful to you Try this
http://www.c-sharpcorner.com/UploadFile/0c1bb2/redirect-page-after-session-time-out-in-Asp-Net424/[^]


这篇关于为什么它不限制我的代码中的直接URL访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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