0

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

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer. Yes the queryFailed function is throwing that error and it's saying that "result is undefined" refering to the function GetMessage for example
0

This solution worked for me : https://cypressnorth.com/programming/solved-using-memory-repository-keys-will-not-persisted-storage-asp-net-core-iis/

Thank you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.