balimaco00
balimaco00

Reputation: 85

Page reloaded automatically after sometime in aspnet core with angularjs

I am developping a web application using AspNet Core with AngualrJS.

I have a problem when a page is opened for sometime and I want to navigate to another page or click on save button. The page reload automatically sending me to default route which is home. And I lose the data entered in the form.

In the console it's written "result undefined" and refering to the service I am calling, exactly to the return line.

Here is an example of service :

function GetMessage(id) {

    var promise = $http.post('api/Gestion/GetMessage', id).then(
        function (data) {
            return data.data;
        }).catch(queryFailed);

    return promise;

}

The same thing happen after publishing some changes to the server.

In my opinion, it's like if the session is destroyed after some minutes.

Do you have any idea how can I remove this delay, and let the session persist if it's really the cause.

And for reloading after publishing, do you suggest a better way to do it transparenlty, instead of losing work of people working on it live.

I am new to this technology, don't hesitate please to change the description to make it too specific if you know the problem

Thank you so much

Upvotes: 0

Views: 41

Answers (2)

georgeawg
georgeawg

Reputation: 48968

For debugging purposes it might be wise to log errors:

function GetMessage(id) {

    var promise = $http.post('api/Gestion/GetMessage', id).then(
        function (response) {
            return response.data;
        }).catch(function(response) {
            console.log("GetMessage ERROR", response);
            queryFailed(response);
        });

    return promise;    
}

Also keep in mind that the queryFailed function needs to throw the response:

function queryFailed(response) {
    //
    // fail handler code here
    //
    throw response;
}

If the function lacks a throw statement, the promise will be converted from a rejected promise to a successful promise.

Upvotes: 1

Related Questions