title: How to secure the data in the post form?
body: <p>I want to know how to secure the data through post method , or it's secure enough ?!</p>
  
  <p>I use the following on my portal :</p>
  
  <pre><code> protected Control CreateCommForm(string action)
          {
              HtmlGenericControl frm = new HtmlGenericControl("form");
              frm.Attributes.Add("method", "post");
              frm.Attributes.Add("target", "_blank");
              frm.Attributes.Add("action", action.TrimEnd());
              /////////////////////////////////////////
              HtmlGenericControl hdn_sal_a = new HtmlGenericControl("input");
              hdn_sal_a.Attributes.Add("id", "hdn_give");
              hdn_sal_a.Attributes.Add("name", "hdn_give");
              hdn_sal_a.Attributes.Add("type", "hidden");
              hdn_sal_a.Attributes.Add("value", Session["empnum"].ToString());
              /////////////////////////////////////////
              HtmlGenericControl hdn_sal_b = new HtmlGenericControl("input");
              hdn_sal_b.Attributes.Add("id", "hdn_give_b");
              hdn_sal_b.Attributes.Add("name", "hdn_give_b");
              hdn_sal_b.Attributes.Add("type", "hidden");
              hdn_sal_b.Attributes.Add("value", Session["secret"].ToString());
              /////////////////////////////////////////
              HtmlGenericControl hdn_sal_result = new HtmlGenericControl("input");
              hdn_sal_result.Attributes.Add("id", "hdn_give_rr");
              hdn_sal_result.Attributes.Add("name", "hdn_give_rr");
              hdn_sal_result.Attributes.Add("type", "hidden");
              hdn_sal_result.Attributes.Add("value", ((99 * int.Parse(Session["secret"].ToString())) + 761).ToString());
              /////////////////////////////////////////
              HtmlGenericControl hdn_sal_h = new HtmlGenericControl("input");
              hdn_sal_h.Attributes.Add("id", "hdn_givel_h");
              hdn_sal_h.Attributes.Add("name", "hdn_give_h");
              hdn_sal_h.Attributes.Add("type", "hidden");
              hdn_sal_h.Attributes.Add("value", role_h.Hash((int.Parse(Session["secret"].ToString()) - 55).ToString(), "SHA512", null));
              /////////////////////////////////////////
              frm.Controls.Add(hdn_give);
              frm.Controls.Add(hdn_give_b);
              frm.Controls.Add(hdn_give_rr);
              frm.Controls.Add(hdn_give_h);
              body.Controls.Add(frm);
              return frm;
  
          }
  </code></pre>
  
  <p>Then </p>
  
  <pre><code>        Control frm = new Control();
          frm = CreateCommForm(process_url);
          Control crl_data = FormContent(block_type, block_id, frm);
          PlaceHolder1.Controls.Add(crl_data);
  </code></pre>
  
  <p>and i check those values in any web site opened from that portal like this:</p>
  
  <pre><code>var hr = HttpContext.Current.Request.UrlReferrer;
  if (hr != null &amp;&amp; !string.IsNullOrEmpty(hr.AbsolutePath))
      {
          if (Request.UrlReferrer.AbsolutePath.Contains("master_portal"))
          {
  
              if (Request.Form["hdn_give"] != null &amp;&amp; !string.IsNullOrEmpty(Request.Form["hdn_give"].ToString())
                 &amp;&amp; Request.Form["hdn_give_b"] != null &amp;&amp; !string.IsNullOrEmpty(Request.Form["hdn_give_b"].ToString()) &amp;&amp;
                 Request.Form["hdn_give_rr"] != null &amp;&amp; !string.IsNullOrEmpty(Request.Form["hdn_give_rr"].ToString()) &amp;&amp;
                 Request.Form["hdn_give_h"] != null &amp;&amp; !string.IsNullOrEmpty(Request.Form["hdn_give_h"].ToString())
                 )
              {
                //------
              }
  </code></pre>
  
  <hr>
  
  <p>Is this 's secure enough ,or there's some better way to do that ? </p>