Skip to content

RemotePost

RemotePost is a utility class that performs a server-side HTTP POST redirect from an ASP.NET web application to a target URL. It accumulates name/value pairs as hidden form fields, then emits a minimal auto-submitting HTML page that causes the browser to POST those fields to the configured destination, bypassing the GET-only limitation of a standard HTTP redirect.

Purpose

  • Accumulate caller-supplied name/value pairs to be emitted as hidden HTML <input> fields.
  • Emit an auto-submitting HTML form targeting a configurable URL via Post().
  • Clear and terminate the current ASP.NET response after emitting the redirect page.

Context

  • Namespace: SAIF.Services.Web
  • Assembly/package: SAIF.Services.Web (distributed as NuGet package SAIF.BOF.Services.Web)

Public members

Member Signature Purpose
AddInput Sub AddInput(Name As String, Value As String) Adds a name/value pair to the internal NameValueCollection (m_Inputs) to be rendered as a hidden <input> field in the generated form.
URL Property URL As String Gets or sets the target URL the generated <form> will POST to (the form action attribute).
FormName Property FormName As String Gets or sets the HTML name attribute of the generated form and the JavaScript document.<FormName>.submit() call; defaults to "form1".
Post Sub Post() Clears HttpContext.Current.Response, writes a minimal HTML document containing an auto-submitting <form> with one hidden <input> per added input pair, then calls Response.End() to terminate the response.

Behavioral notes

  • Post() operates exclusively against HttpContext.Current; if called outside an active ASP.NET web request context, a NullReferenceException will occur at runtime.*
  • Caller-supplied Name/Value pairs are written directly into HTML <input> attribute values via String.Format with no HTML-encoding applied; values containing HTML special characters may produce malformed markup or enable injection if untrusted input is passed.*
  • The internal field m_Inputs is a System.Collections.Specialized.NameValueCollection used to accumulate all added pairs before Post() emits the form.
  • Despite the project declaring an extensive NuGet dependency graph (SAIF.BOF.Framework, SAIF.Web.API.Clients, Oracle.ManagedDataAccess, RestSharp, Newtonsoft.Json), none of these are referenced by this class — the only runtime dependencies are System.Web.HttpContext and System.Collections.Specialized.NameValueCollection.*

Constraints and usage notes

  • Must be called from within an active ASP.NET web request (requires a non-null HttpContext.Current).
  • URL should be set before calling Post(); an unset URL results in an empty action attribute, causing the browser to POST back to the current page.
  • FormName defaults to "form1" and may be left at its default unless the calling page already uses that name for another form element.
  • Post() terminates the ASP.NET response via Response.End(); no further server-side processing occurs after this call.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Services\SAIF.Services.Web\RemotePost.vb
  • Services\SAIF.Services.Web\SAIF.BOF.Services.Web.vbproj