Detecting Refresh or Postback in ASP.NET

One of the biggest challenges for web developers is the resubmission of form data or the refresh of a form to post information to a database. This happens when the user, for whatever reason, resubmits or refreshes the form, which has the potential to cause chaos with duplicated database insertions or repeated email submissions.
In this article I Will show you how to define page is postback or refresh after postback.
Here my simple code

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["PostID"] = "1001";
            ViewState["PostID"] = Session["PostID"].ToString();
            Response.Write("First Load");
        }
        else
        {
            if (ViewState["PostID"].ToString() == Session["PostID"].ToString())
            {
                
                Session["PostID"] = (Convert.ToInt16(Session["PostID"]) + 1).ToString();

                ViewState["PostID"] = Session["PostID"].ToString();
                Response.Write("Postback");

            }
            else
            {
                ViewState["PostID"] = Session["PostID"].ToString();
                Response.Write("refreshed");

            }
        }
    }

Thanks