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 4618554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:01+00:00 2026-05-22T02:17:01+00:00

I have 2 forms on the same page. One is a form in a

  • 0

I have 2 forms on the same page. One is a form in a partial view which is rendered via a child action we’ll call this PodForm. The second is rendered by the current action.

So my code looks a little like this (please ignore names etc, this is example code):

Form.cshtml

@model MyProject.Models.FormInputModel
@using(Html.BeginForm("Form","Main",FormMethod.Post))
{
  @Html.TextBoxFor(x=>x.AField)
  @* Some other fields *@
  <input type="submit"/>
}

<div class="sidebar">
   @Html.Action("PodForm","Pod")
</div>

PodForm.cshtml

@model MyProject.Models.PodFormInputModel
@using(Html.BeginForm("PodForm","Pod",FormMethod.Post))
{
  @Html.TextBoxFor(x=>x.Name)
  @* Some other fields *@
  <input type="submit"/>
}

When I click submit on the Main form, the PodForm action method is triggered. What’s going on?

Edit – As requested in the comments:

  1. The generated mark up looks similar to the following.

    <form action="/Main/Form" encoding="multipart/form-data" method="POST">
         <input type="text" name="AField" />
         <input type="submit" />
      </form>
    
     <div class="sidebar">
       <form action="/Pod/PodForm" method="POST">
           <input type="text" name="Name" />
           <input type="submit" />
       </form>
     </div>
    
  2. Controller actions

    The “MainController” (not the actual name) has an action called “Form”

    public MainController : Controller
    {
        public ActionResult Form()
        {
            return View();
        }
    
        [HttpPost]
        public ActionResult Form()
        {
            if(ModelState.IsValid)
            {
              //Save
            }
    
            return View();
        }
    }
    

    The “PodController” (not the actual name) has an action called “PodForm”. The Reason the HttpPost does not return View is that doing that from a child action returns just the partial view – not what I want.

        public PodController : Controller
        {
           public ActionResult PodForm()
           {
              return View();
           }
    
           [HttpPost]
           public ActionResult PodForm(PodFormInputModel model)
           {
              if(ModelState.IsValid)
              {
                 //Save the thing   
    
                  return RedirectToAction(Request.HttpReferrer.ToString()).AndFlash("Saved");
              }
    
              return RedirectToAction(Request.HttpReferrer.ToString()).AndFlash("Not saved");
           }
        }
    

UPDATE: I have figured out that the first action method is called but because it returns a View() the view engine is calling the PodForm action method as a Post rather than as a Get which is triggering the submit logic. Weird.

  • 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-05-22T02:17:02+00:00Added an answer on May 22, 2026 at 2:17 am

    I have worked out that the Action method for the main form is getting hit first and responding correctly. However, when the view for the main form renders, the child action for the pod form also renders but because the request was a post it renders the HttpPost action method, causing the problem.

    I’ve fixed it by renaming the HttpPost method and changing the PodForm.cshtml to use this new action method.

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

Sidebar

Related Questions

I have 3 forms at the same page and each has a different form
I have several forms(user can add new form dynamically) in one page, they're all
I have two forms on one page: a results form and a search form.
When two forms on one page have the same-named field, Django will generate invalid
I have a couple of forms on one page without a form name. Each
I have several forms on one page, they're all the same, but have different
I have a page which dynamically creates multiple forms, each form had a unique
How can two forms share the same inputs? I have two forms, one for
I have an application with multiple forms, each form has the same icon, so
I have WPF Form which has many buttons with the same code. Appearance of

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.