c# - post form data to another page without __VIEWSTATE variable in query string -


currently working on payment gateway integration asp.net application, in have post few form variables payment gateway page using method. when using simple html page using form controls hold values , post external payment gateway page working fine.

when trying inside of asp.net c# application, getting error "validation of viewstate mac failed. if application hosted web farm or cluster, ensure configuration specifies same validationkey , validation algorithm. autogenerate cannot used in cluster.". on checking query string getting posted external payment gateway page asp.net c# page there additional __viewstate variable appended desired query string holds variable values want post payment gateway page.

i have made enableviewstate="false" enableeventvalidation="false" enableviewstatemac="false" <%page%> directives in aspx page , added "this.enableviewstate = false" in overridden onload method in code behind.

for reference adding code snippets below:

aspx page

<body>     <%--<form id="pgform" name="pgform" action="http://xxx.xx.xx.xx:xxxx/_layouts/portal/ewallet_billdesk_dummy.aspx" method="post" runat="server">  --%>     <form id="pgform" name="pgform" action="http://xxx.xxx.xx.xx:xxxx/paymentgateway.aspx"     method="get" target="_blank" runat="server">     <asp:hiddenfield id="mid" runat="server"></asp:hiddenfield>     <asp:hiddenfield id="mtrxid" runat="server"></asp:hiddenfield>     <asp:hiddenfield id="mitem" runat="server"></asp:hiddenfield>     <asp:hiddenfield id="amount" runat="server"></asp:hiddenfield>     <script type="text/javascript">         document.pgform.submit();         //alert("connector fired");     </script>     </form> </body> 

code behind

    protected override void onload(eventargs e)         {             this.enableviewstate = false;             base.onload(e);         }                 protected void page_load(object sender, eventargs e)         {                 byte[] encrkeystream = encoding.utf8.getbytes("nlxck}~mwgf1wxrt");                 if (request.querystring["c"] != null)                 {                     string qry = converthextostring(request.querystring["c"]);                     string strapplicationno = qry.split('|')[0];                     string strtxnamount = "1";//qry.split('|')[1];                     string mtrxid = "abcmi" + strapplicationno;                     string mitem = "motor insurance";                     string encmtrxid = encryptdecrypt.encrypt(mtrxid, encrkeystream);                     string encmitem = encryptdecrypt.encrypt(mitem, encrkeystream);                     string encamount = encryptdecrypt.encrypt(strtxnamount, encrkeystream); ;                       mid.value = "abc_dev";                     mtrxid.value = encmtrxid;                     mitem.value = encmitem;                     amount.value = encamount;                  } } 

please me in regard. need solution it's been quite few hours & unable find 1 solution. requesting help.

thanks in advance.

don't use <form runat="server" /> or server-side controls. use standard <form> , normal <input> fields (all without runat="server") instead. way asp.net won't generate view state or other hidden fields on behalf, , can submit form cross-host.

i caution have security expert audit code , use of cryptography.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -