Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 33235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:53:20+00:00 2026-05-10T13:53:20+00:00

ASP.NET server-side controls postback to their own page. This makes cases where you want

  • 0

ASP.NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (for authentication, for instance) a pain.

An HttpWebRequest works great if you don’t want to redirect, and JavaScript is fine in some cases, but can get tricky if you really do need the server-side code to get the data together for the post.

So how do you both post to an external URL and redirect the user to the result from your ASP.NET codebehind code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T13:53:21+00:00Added an answer on May 10, 2026 at 1:53 pm

    Here’s how I solved this problem today. I started from this article on C# Corner, but found the example – while technically sound – a little incomplete. Everything he said was right, but I needed to hit a few external sites to piece this together to work exactly as I wanted.

    It didn’t help that the user was not technically submitting a form at all; they were clicking a link to go to our support center, but to log them in an http post had to be made to the support center’s site.

    This solution involves using HttpContext.Current.Response.Write() to write the data for the form, then using a bit of Javascript on the <body onload=''> method to submit the form to the proper URL.

    When the user clicks on the Support Center link, the following method is called to write the response and redirect the user:

    public static void PassthroughAuthentication() {      System.Web.HttpContext.Current.Response.Write('<body      onload=document.forms[0].submit();window.location=\'Home.aspx\';>');      System.Web.HttpContext.Current.Response.Write('<form name=\'Form\'      target=_blank method=post      action=\'https://external-url.com/security.asp\'>');      System.Web.HttpContext.Current.Response.Write(string.Format('<input         type=hidden name=\'cFName\' value=\'{0}\'>', 'Username'));      System.Web.HttpContext.Current.Response.Write('</form>');     System.Web.HttpContext.Current.Response.Write('</body>'); } 

    The key to this method is in that onload bit of Javascript, which , when the body of the page loads, submits the form and then redirects the user back to my own Home page. The reason for that bit of hoodoo is that I’m launching the external site in a new window, but don’t want the user to resubmit the hidden form if they refresh the page. Plus that hidden form pushed the page down a few pixels which got on my nerves.

    I’d be very interested in any cleaner ideas anyone has on this one.

    Eric Sipple

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the use of server-side controls is a no-no in ASP.NET MVC, however
I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)
For the ASP.NET validator controls, I want to use both client-side validation for the
What is the recommended approach to reference ASP.NET server side controls in JQuery?Currently I
I'm thinking to add some code on the server side in asp.net, to verify
The Problem When using asp.net server controls id attributes such as the following are
Which are the events of an ASP .Net server control and how does their
I am trying to use ASP.NET Server Controls (ASP.TextBox etc) with MVC (to take
I have an ASP.NET page with two instances of the same Web User Control
Is there a way to add asp.net server side control dynamically on the webpage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.