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

  • Home
  • SEARCH
  • 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 8285263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:25:37+00:00 2026-06-08T11:25:37+00:00

Say I have the following form that’s in classic asp: <form name=impdata id=impdata method=POST

  • 0

Say I have the following form that’s in classic asp:

<form name="impdata" id="impdata" method="POST" action="http://www.bob.com/dologin.asp">
<input type="hidden" value="" id="txtName" name="txtName" />
</form>

I need to simulate the action of submitting the form in asp.net mvc3, but I need to modify the hidden value before submitting. Is it possible to do this from the action or in another way?

What I have so far…

View:

@using (Html.BeginForm("Impersonate", "Index", FormMethod.Post, new { id = "impersonateForm" }))
{                       
    <input id="Impersonate" class="button" type="submit" value="Impersonate" action />
    <input type="hidden" value="" id="txtName" name="txtName" />
}

Controller:

[HttpPost]
public ActionResult Impersonate(string txtName)
{
txtName = txtName + "this string needs to be modified and then submitted as a hidden field";  
//Redirect won't work needs the hidden field
//return Redirect("http://www.bob.com/dologin.asp");
}

Solution:

Seems that it isn’t easy to do this from the controller so I ended up using jQuery. The action returns a JsonResult.
Something like:

<button id="Impersonate" class="button" onclick="Impersonate()">Impersonate!</button>

<form name="impdata" id="impersonateForm" action="http://www.bob.com/dologin.asp">
  <input type="hidden" value="" id="txtName" name="txtName" /> 
</form>

function Impersonate() {           
    $.ajax({
        type: 'POST',
        asynch: false,
        url: '@Url.Action("Impersonate", "Index")',
        data:
            {
                name: $('#txtName').val()                    
            },
        success: function (data) {                
            $('#txtName').val(data.Name);              
            $('#impersonateForm').submit();               
        }
    });

Seems to work well…

  • 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. Editorial Team
    Editorial Team
    2026-06-08T11:25:40+00:00Added an answer on June 8, 2026 at 11:25 am

    It is rather hard to redirect to a POST from a POST (relies on HTTP status codes without universal support), and it is impossible from a GET.

    The simplest solution is probably a little JavaScript on the result that posts the (new) form.

    Thus you action method returns a view with the necessary data in it (passed via the model from the controller) which will include the JavaScript.

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

Sidebar

Related Questions

Lets say that you have a following simple application: <form action=helloServlet method=post> Give name:<input
Let's say I have the following scenario: <form action=/something.php method=GET>Click me</div> <script type=text/javascript><!-- $('form').submit(function(e)
I need some help with something... say I have the following form... <form name=
Let's say I have a string in the following form: myString={name, age, address, contacts,
Let's say I have the following code in a form that is triggered on
say for instance I have the following button in a form in asp.net mvc
Lets say I have a working form that looks like the following =form_for @survey
Say I have the following chef role: name test description role for test run_list
Let's say that I have specified the following WCF REST Service at the address
Let's say I have a form in C# containing textboxes that correspond to fields

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.