文件夹名称应重定向到文件夹外的页面 [英] Folder name should redirect to a page which is out side the folder

查看:87
本文介绍了文件夹名称应重定向到文件夹外的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我通过以下网址时:www.abcd.com/Admin



它应该重定向为:www.abcd.com/Login.aspx



我怎样才能得到它,请帮助..

Hi,

When i pass URL like : www.abcd.com/Admin

It should redirect as : www.abcd.com/Login.aspx

How can i get it, please help..

推荐答案

最好的方法是实现成员身份: http://msdn.microsoft.com /en-us/library/yh26yfzy.aspx [ ^ ]

如果你这样做,它变得微不足道,系统将为你处理所有这些事情。
The best way is to implement Membership: http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx[^]
If you do this, it becomes trivial and the system will handle all such things for you.


方法1:使用会员资格

了解ASP.NET角色和成员资格 - 初学者教程 [ ^ ]



方法2:使用会话变量

method 1 :use membership
Understanding ASP.NET Roles and Membership - A Beginner's Tutorial[^]

Method 2:Use the session variable
Use the session variable in the page_load:

protected void Page_Load(object sender, EventArgs e)
{
    Session["loggedin"] = "false";
}
... and check the login event. If user has pressed the login button then set the session variable "true".

protected void btnOK_Click(object sender, EventArgs e)
{
    Session["loggedin"] = "true";
    ......
   ......
}
When the page is redirected to another page then check the status of the session variable in page load event.

    try
    {

        if (Session["loggedin"].ToString() == "false")
        {
            Response.Write("<script> alert('Session Expires! please login first'); </script>");

            Response.Redirect("login.aspx");
            return;
        }

    }
    catch (Exception er)
    {
        Response.Redirect("login.aspx");
    }







快乐编码:)




Happy Coding :)


这篇关于文件夹名称应重定向到文件夹外的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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