0

As i have followed certain links to which i used but none of the answers helped me.
Disabling backbutton of browser in C#
https://www.aspsnippets.com/Articles/Disable-Browser-Back-Button-using-JavaScript-jQuery-in-ASPNet-MVC.aspx
disable browser back button javascript
https://www.itsolutionstuff.com/post/how-to-disable-browser-back-button-using-jqueryexample.html

Following of the code which i have used in cshtml page.

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta Http-Equiv="Cache-Control" Content="no-cache" />
    <meta Http-Equiv="Pragma" Content="no-cache" />
    <meta Http-Equiv="Expires" Content="0" />
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Content/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //window.history.pushState(null, "", window.location.href);
            //window.onpopstate = function () {
            //    window.history.pushState(null, "", window.location.href);
            //};

        });
        //function disablePrev() { window.history.forward(1) };
        //window.onload = disablePrev();
        //window.onpageshow = function (evt) { if (evt.persisted) disableBack() };
        //window.history.forward(1);
        //function noBack() { window.history.forward(1); }
        function disableBackButton() 
        {
            window.history.forward()
        }
        disableBackButton();
        window.onload = disableBackButton;
        window.onpageshow = function (evt) { if (evt.persisted) disableBackButton() }
        window.onunload = function () { void (0) }
    </script>
</head>
<body önunload="disableBackButton()">
    <div>
    </div>
</body>
</html>

As i am using version of chrome Version 83.0.4103.116 (Official Build) (64-bit) and firefox version 78.0.2 (64-bit). Please suggest any other solution as none of the answer are working for me.

Kapil Gupta
  • 31
  • 1
  • 2
  • First, your `script` should be at the bottom of your code, in the body. Second, your `onunload` is misspelled as `önunload`. Your problem was a misspelling. – Anvay Jul 13 '20 at 07:51
  • @Anvay i have tried this solution as well. Actually i was looking for an answer as well. But still their is no solution as of now. –  Jul 13 '20 at 11:31
  • @Anvay i have tried same but its not working. Please give some another solution. – Kapil Gupta Jul 13 '20 at 11:32

0 Answers0