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 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 two forms on a page (one is being grabbed by AJAX). I
I need to have multiple forms in the same webpage, all of them POSTing
I have 2 handlers using the same form. How do I remove the handlers
I have two different grid controls on the same form. They share the same
I have forms in my page a get and a post and i want
I have two forms, form A and form B. These forms must differ in
I have some forms that communicate with server using AJAX for real reasons: cascade
I have two forms in my rails app. They both exist in separate tabs
Hi have some forms that I want to use some basic php validation (regular
Contributing to open source can have many forms: working with issue trackers, patches, further

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.