title: detect page refresh jQuery or C# ASP.Net
body: <p>I was searching for a way of detecting in my C# code if the page had been refreshed (f5). </p>
  
  <p>First I don’t know if a jQuery/JavaScript solution would be better than a fully C# ASP.Net. So... the first question would be: What would make you choose one over the other?</p>
  
  <p>And the third, and most important part, is if someone would help me with this. Some good tutorial, or article… anything. I tried some solutions out there… but maybe, because of my lack of knowledge they didn’t work.</p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <h2>update 1</h2>
  
  <p>I tried to do Hightechrider solution, because it seems pretty simple to implement. So I typed this code:</p>
  
  <pre><code>public bool IsRefresh { get; set; }
  
  protected override void OnPreInit(EventArgs e)
  {
      base.OnPreInit(e);
  
      IsRefresh = false;
      if (Page.Request.AppRelativeCurrentExecutionFilePath == Profiles.User.LastPageUrl &amp;&amp;
          !Page.IsPostBack)
          IsRefresh = true;
  }
  </code></pre>
  
  <p><em>PS: The Profiles.User.LastPageUrl is a session variable that I have created for other purposes, but suites the needs of this one to. So that is not some built in property.</em></p>
  
  <p>However, after a couple of tests I got to the conclusion that a page could be a PostBack and Refresh at the same time. Because a user could press a button and after that, hit refresh. So this scenario invalidates my previous code, because of the !Page.IsPostBack.
  I am still seeking for a simple straight solution to this.</p>