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

[Solved] Cannot Read the HTTP Response Header

3 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Houssam Hamdan
Top achievements
Rank 1
Houssam Hamdan asked on 29 Jun 2011, 08:05 AM
Greetings,

When the session times out, am adding a key to the HTTP Response Header on the server side. Unfortunately, I did not find a way to read it on Grid client events such as OnDataBinding(). Could you please help me in this ?

Thank you in advance

3 Answers, 1 is accepted

Sort by
0
Houssam Hamdan
Top achievements
Rank 1
answered on 04 Jul 2011, 07:47 AM
Hello again,

If it is not possible to read the response header, please recommend an adequate solution when the session times out.

Cheers
0
Atanas Korchev
Telerik team
answered on 04 Jul 2011, 08:34 AM
Hi Houssam Hamdan,

 The XmlHttpRequest is exposed only in the OnError event of the grid which occurs in case of server-side errors, timeouts etc. You can use that event and perform client-side redirects to the login page when there is a session timeout.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Houssam Hamdan
Top achievements
Rank 1
answered on 06 Jul 2011, 12:18 PM
Hi Atanas,

Thank you for the reply.

I can not use your approach because i am handling the session timeout by sending a JSON object as an http response instead. What i need is to get the XmlHttpResponse. Why dont you expose it instead/along with the XmlHttpRequest on client events?

Anyhow, to whom this may concern, I solved it by removing a cookie variable with server side code and then check if that cookie exists on the client side as follows:

Server Side Code:
this.Response.Cookies.Add(new System.Web.HttpCookie("token")
            {
                Expires = DateTime.Now.AddDays(-1),
                Path = "/"
            });

Client Side Code:
 $("div.name").ajaxComplete(function (e) {
        var token = $.cookie('token');
        if (token == null) {          
            alert('Your session has expired.');
        }
    });

Cheers
Tags
Grid
Asked by
Houssam Hamdan
Top achievements
Rank 1
Answers by
Houssam Hamdan
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or