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

Microsoft recommends their Script Encoder to encode asp.net scripts on server side from nosy/prying
I've an asp.net page having a server side submit button and 2 textboxes which
For the ASP.NET validator controls, I want to use both client-side validation for the
I have an ASP.NET webform which I want to validate Client-Side and Server-Side, using
I have a dropdownlist in my asp.net web page. Its a server side control.
What is the recommended approach to reference ASP.NET server side controls in JQuery?Currently I
I know the use of server-side controls is a no-no in ASP.NET MVC, however
I've been developing traditional ASP.NET applications with server side ASP.NET controls and code behind
I require ASP.NET server side code in a SVG that I created. To accomplish
How does one pass string contains '\' from from asp.net server side to javascript

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.