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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:37:23+00:00 2026-05-13T07:37:23+00:00

I hope I am able to put this question together well. In a partial

  • 0

I hope I am able to put this question together well.
In a partial view I have a link to a create action:

public ActionResult CreateProject()
{
    return View("EditProject", new Project());
}

Now this loads another view which allows editing of the blank model passed to it. But when form is submitted it is supposed to post to:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditProject(Project record)
{
    if (ModelState.IsValid)
    {
        projectRepo.saveProject(record);
        return View("Close");
    }
    else
    {
        return View("EditProject");
    }
}

This method works for many of the tables and edit actions work just as well for the same view. But only for the create action (with the blank model) the form keeps calling to the create action, as I traced with the debugger.

One of my team mates has solved this problem so:

[AcceptVerbs(HttpVerbs.Get)]
public ViewResult EditProject(int id)
{
    Project project = null;
    if (id == 0)
    {
        project = new Project();
    }
    else
    {
        project = (from p in projectRepo.Projects
                   where p.ProjectID == id
                   select p).First();
    }

    return View(project);
}

And in the partial instead of having <%= Html.ActionLink("Create New", "CreateProject")%> there’d be <%= Html.ActionLink("Create New", "CreateProject", new { id = 0 })%>.

Now I was hoping to find out why the previous method would not go through, since it does for other tables in other views. Thanks.

  • 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-13T07:37:23+00:00Added an answer on May 13, 2026 at 7:37 am

    By default your form will post to same URL it was rendered at. Since you called create action it will post back to create action, and not edit, ‘cos views do not matter (-:

    Explicitly use

     <%= using( Html.BeginForm("Action","Controller) ){ %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this question does not come off as broad as it may seem
I hope everyone will pardon the length, and narrative fashion, of this question. I
I hope this question is not considered too basic for this forum, but we'll
I hope this is programmer-related question. I'm in the hobby business of C# programming.
I hope this is a simple enough question for any SQL people out there...
I hope someone can help us. We’re trying to put together an image editor,
Hope anyone can shed light on this so I can use pens with dash
I hope there's a SharePoint expert here on SO who can help with this.
I hope this isn't considered a duplicate since it's more pointed than similar questions
thank you for taking your time to read this message. I hope you are

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.