title: How to detect if Refresh button(F5) is pressed
body: <p>I have the below code</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
             //do something 
          }
          else
          {
              // do something else
          }
      }
  
      protected void Button1_Click(object sender, EventArgs e)
      {
          //do something       
      }
  }
  </code></pre>
  
  <p>The point is that a post back happens if I press F5/refresh button or a button click. How will I prevent the code from doing any action if F5/refresh button is clicked?</p>
  
  <p>I have checked <a href="https://stackoverflow.com/questions/908075/detect-f5-being-pressed-and-refresh">Detect F5 being pressed and Refresh</a> but the solution of mine will be different as I need to do this in C# code.</p>
  
  <p>Thanks</p>