locked
Response.End() RRS feed

  • Question

  • User-1578974752 posted

      Response.End()

    When I click a button in the result form ,then   Response.End() will be called. But from that form (End) I can go back to  result form.

    How can I prevent user to click back arrow(windows) of the response. End form

    Thanks

    Wednesday, October 30, 2019 3:41 AM

Answers

All replies

  • User288213138 posted

    Hi shsu,

    When I click a button in the result form ,then   Response.End() will be called. But from that form (End) I can go back to  result form.

    what is form(End)? What is the relationship between him and the result form?

    How can I prevent user to click back arrow(windows) of the response. End form

    Do you want to disable the goback button on the page? If so, you can try below code.

    The preventBack() method disable the goback button.

    <script type="text/javascript">
            function preventBack() { window.history.forward(); }
            setTimeout("preventBack()", 0);
            window.onunload = function () { null };
        </script>
    
    <form id="form1" runat="server">
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </form>
    
    protected void Button1_Click(object sender, EventArgs e)
            {
                Response.Write("This is the refreshed page");
            }

    The result:

    Best regards,

    Sam

    Wednesday, October 30, 2019 7:03 AM
  • User-1780421697 posted

    There are 4 solutions describe here

    https://lennilobel.wordpress.com/2009/07/26/defeat-the-evil-back-button-in-your-asp-net-applications/

    For Server Side:

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);
     
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
        Response.Expires = -1500;
        Response.CacheControl = "no-cache";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2019 10:33 AM
  • User-1578974752 posted

    Thanks, If I want to show a message in the Response.end form  then how can I do that?

    Thursday, October 31, 2019 2:22 AM
  • User288213138 posted

    Hi shsu,

    This is a new question, please post your question in new thread.

    Best regards,

    sam

    Thursday, October 31, 2019 9:20 AM