locked
Request.form values are empty RRS feed

  • Question

  • User351619809 posted

    I am redirecting my web site to a outside vendor payment web site. Web site gets redirected successfully. Once the payment is done outside vendor gives the value in the post. I capture the value using Request.Form. When I checked the the browser developer tools Network tab, I noticed - the POST request is successfully completed but immediately followed by a GET request. After searching around in Google. I Commented out the entire body of the RegisterRoutes method in the RouteConfig.cs file. I also cleared the browser cache programmatically, but still the value is null. Below is my code:Code for .aspx page

    <asp:LinkButton runat="server" ID="btnNext" Text="Place your Order"  data-role="button" class="ss-right" data-inline="true" data-theme="b"  data-iconpos="right" OnClick="btnplaceOrder_click"  data-icon="check" CausesValidation="true"  ></asp:LinkButton>
    protected void btnplaceOrder_click(object sender, EventArgs e)
      {
           // sending some data to outside vendor
          // outside vendor give me URL with a GUID appended to URL
                        clearCache();
                        Response.ClearHeaders();
                        Response.ClearContent();
                        Response.DisableUserCache();
            Response.Redirect("https://outsidevendorURL);
    
    
       }




     private void clearCache()
            {
                Response.CacheControl = "no-cache";
                Response.AddHeader("Pragma", "no-cache");
                Response.Expires = -1;
    
            }


    This is how I capture the value:code for .aspx page:

    <body>
        <form id="form1" runat="server" method="post">
       </form>
    <body>

    code for .cs page:

     protected void Page_Load(object sender, EventArgs e)
            {
               
                if (!IsPostBack)
                {
    
                    NameValueCollection nvc = Request.Form;
                }
            }

    Request.Form is totally empty in some cases and sometimes Request.Form has value in it. I am not sure what am I doing wrong.

    I already looked at the following answers:

    https://www.mikesdotnetting.com/article/293/request-form-is-empty-when-posting-to-aspx-page

    Below is the image from developers tool.

    <div> </div> <div>The first Receipt is post and second one is Get</div>

    any help will be highly appreciated.

    Friday, February 19, 2021 1:25 AM

Answers

All replies