This is a migrated thread and some comments may be shown as answers.

RadAjaxPanel.Redirect Failing to Redirect

1 Answer 143 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 23 Nov 2016, 06:15 PM

Hello, I have an old project I am upgrading to the most recent Telerik Release and I'm running into issues while redirecting from a login page.

 

The code is pretty straight forwards,. the Default.aspx page looks something like this:

protected void Page_Load(object sender, EventArgs e)
        {           
            if (Context.Session != null)
            {
                if (Session.IsNewSession)
                {
                    string szCookieHeader = Request.Headers["Cookie"];
                    if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
                    {
                        Response.Redirect("/Login.aspx");
                    }
                }
            }
             
            if (!Convert.ToBoolean(Session["UserIsAdmin"]))
            {
                //Acquire appropriate redirect path from database
                 
                Response.Redirect(redirectPath);
 
            }
            else
            {
                Response.Redirect("/Modules/Admin/UserSetup.aspx");
            }           
        }

 

and the login page has a username and password field with a log in button that looks like so:

 

protected void bLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (allowLogin)
                {
                    UserClass userAuthenticationClass = new UserClass(eUsername.Text, ePassword.Text);
                    if (userAuthenticationClass.IsValidUser)
                    {
                        string s = FormsAuthentication.DefaultUrl;
                        Session["User"] = userAuthenticationClass;
                        Session["UserID"] = userAuthenticationClass.UserID;
                        Session["Username"] = userAuthenticationClass.Username;
                        Session["UserMasterID"] = userAuthenticationClass.UserMasterID;
                        Session["UserIsAdmin"] = (eUsername.Text.ToUpper() == "ADMINISTRATOR") ? "True" : "False"
                        Session["UserType"] = userAuthenticationClass.UserType;
                        Session["EmailAddress"] = userAuthenticationClass.EmailAddress;
                        Session["SessionID"] = Guid.NewGuid().ToString();
 
                        Session.Timeout = 1440;
 
                        AppCode.SessionStatistics.InsertStatistic(Session["SessionID"].ToString(), Session["UserID"].ToString());
 
                        RadAjaxPanel1.Redirect("/Default.aspx");
                        //FormsAuthentication.RedirectFromLoginPage(eUsername.Text, false);
                        //Response.Redirect("/Default.aspx", false);
                        //Server.Transfer("/Default.aspx", false);
                        //Server.Execute("/Default.aspx", true);
                         
                    }
                    else
                    {
                        LabelMessage.Text = "Could Not Authenticate User";
                    }
                }
            }
            catch (Exception ex)
            {
                LabelMessage.Text = ex.Message;
            }           
        }

 

So Here's where it gets odd. When debugging from Visual Studio, this works correctly. when running on my local web server (set up on my development machine) this also works correctly. but when deployed to a test server, the login button just does not redirect. (it clicks, authenticates the user, then returns to the login page)

 

I was wondering if it's possible that there is something happening that would cause the Session variables to be lost when using RadAjaxPanel.Redirect?

 

Keep in mind, this method works perfectly fine on the development environment. Is there anything I need to install/set up on the test environment for this to work?

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 23 Nov 2016, 07:33 PM
Hello Adam,

This forum post has been converted to a support ticket.  Please see your support tickets for more information.

Regards,
Patrick
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
Ajax
Asked by
David
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or