在会话超时时注销到相应的登录页面 [英] On session timeout Logout to the respective Login Page

查看:76
本文介绍了在会话超时时注销到相应的登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我开发了一个asp .net应用程序,患者和医生有两种类型的用户。用户的登录页面不同,但登录页面相同后,根据用户类型启用和禁用某些控件。

我需要在会话超时时注销并重定向到相应的登录页面。



目前我这样做,



Hi Friends,

I have developed an asp .net application,There are two type of users patient and doctor. Login pages are different for the users but after login pages are same for both some controls are enabled and disabled based on the type of user.
I need to logout and redirect to the respective login page on session timeout.

Currently i'm doing like this,

public class PageBase : System.Web.UI.Page
{
    public PageBase()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    protected override void OnPreRender(EventArgs e)
    {

        base.OnPreRender(e);
        if(string.IsNullOrEmpty(Convert.ToString(Session["USERID"])))
            Response.Redirect(ConfigurationManager.AppSettings["InternalUrl"].ToString());

    }

}







请看看上面的代码。

我将用户重定向到基于会话null或空的登录页面。但在这里我需要找到用户的类型,以便我可以给出重定向URL。




Please have a look at the above code.
i'm redirecting the user to login page based on the session null or empty. But here i need to find the type of user, so that i can give the redirect URL.

推荐答案

这很简单。 :)

登录按钮单击,在会话中存储用户类型。正如您所说的那样,两个用户的登录页面都不同,那么这不是问题。例如,



如果医生登录,点击登录按钮,

会话[UserType ] =doc;



在另一页上,执行以下操作,

It's pretty simple. :)
On Login Button Click, Store the type of user as well in the Session. As you've said that Login pages are different for both the users, then it won't be an issue. For example,

If Doctor is logging in, on button click of login,
Session["UserType"] = "doc";

And on the other page, do something like following,
protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    if(string.IsNullOrEmpty(Convert.ToString(Session["USERID"])))
        Response.Redirect(ConfigurationManager.AppSettings["InternalUrl"].ToString());

    if(string.IsNullOrEmpty(Convert.ToString(Session["UserType"])))
        Reponse.Redirect("SomePage.aspx");
}



-KR


-KR


这篇关于在会话超时时注销到相应的登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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