locked
Page does not redirect to the login page when setting window.location in JavaScript RRS feed

  • Question

  • User2143564534 posted

    Hi,can anyone please assist me with the issue window.location="Login.aspx"; i am trying to redirect to login after session timeout,it gives an error below please kindly advice, what is it that i am missing.

    Thank you in advance.

    <script type="text/javascript">
    function SessionExpireAlert(timeout) {
    var seconds = timeout / 1000;
    document.getElementsByName("secondsIdle").innerHTML = seconds;
    document.getElementsByName("seconds").innerHTML = seconds;
    setInterval(function () {
    seconds--;
    document.getElementById("seconds").innerHTML = seconds;
    document.getElementById("secondsIdle").innerHTML = seconds;
    }, 1000);
    setTimeout(function () {
    //Show Popup before 20 seconds of timeout.
    $find("mpeTimeout").show();
    }, timeout - 20 * 1000);
    setTimeout(function () {
    window.location="Login.aspx";


    }, timeout);

    };
    function ResetSession() {
    //Redirect to refresh Session.
    window.location = window.location.href;
    }
    </script>

    Server Error in '/' Application.


    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

    Requested URL: /Admin/Login.aspx


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2110.0

    Wednesday, January 24, 2018 12:19 PM

Answers

  • User-707554951 posted

    Hi Eosia:

    According error message, please make sure login page exist in your Admin folder.

    May be you need the code below:

      window.location = "../Login.aspx";

    Best regards

    Cathy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 25, 2018 9:37 AM

All replies

  • User-707554951 posted

    Hi Eosia:

    According error message, please make sure login page exist in your Admin folder.

    May be you need the code below:

      window.location = "../Login.aspx";

    Best regards

    Cathy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 25, 2018 9:37 AM
  • User2143564534 posted

    Thank you so much Cathy...it works

    Thursday, January 25, 2018 10:01 AM