直接访问.aspx页 [英] Direct Access to a .aspx page

查看:88
本文介绍了直接访问.aspx页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何通过直接访问home.aspx来限制用户?
我的应用程序的默认页面是Login.aspx(例如: http://www.xyz.com/app )
它将打开login.aspx.
问题是,如果用户键入 http://www.xyz.com/app/home.aspx ,那么它将直接打开home.aspx.
我想限制它.
有人可以告诉我该怎么做吗?

谢谢
Thiru

Hi,

How Can i restrict the User by accessing home.aspx directly?
default page for my Application is Login.aspx ( eg: http://www.xyz.com/app )
It will opens login.aspx.
The problem is if user type http://www.xyz.com/app/home.aspx then it is opening home.aspx directly.
I want to restrict it.
Can anybody tell me how to do this?

Thanks
Thiru

推荐答案

对用户进行身份验证后,创建一个指示该身份的会话对象.在每个页面中,检查该会话对象是否具有已验证的值.
像这样的东西:
After a user is authenticated, create a session object indicating that. In every page check if that session object has the authenticated value.
Something like:
//In the login page, after user is authenticated
Session["validated"] = true;

//In every page that requires authentication, On page load event, check
if(Session["validated"] == null)
    Response.Redirect("Login.aspx");
else
    //do what you want here.


您应该阅读-如何在web.config文件中进行授权
这将使您了解如何在配置文件中设置选项,从而使任何人都可以在不登录的情况下尝试访问任何页面,那么他/她将被重定向到您的登录页面.
you should read - how to do authorization in web.config file
this will make you understand how you can set the options in config file in such a way that if any person tries to access any page without logging in, he/she will be redirected to your login page.


在身份验证中检查凭据,然后确定credentals是否正确,然后使用表单身份验证(在web.config中)重定向到home.aspx.否则重定向到登录页面.
in authentication check credentials then if credentals are true redirect to home.aspx otherwise redirect to login page.using forms authentication(in web.config).


这篇关于直接访问.aspx页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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