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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:55:46+00:00 2026-05-29T06:55:46+00:00

Bear with me as I describe the issue. An MVC3 application making use of

  • 0

Bear with me as I describe the issue.

An MVC3 application making use of partial views. Having trouble posting a Comments form in a partial view from its parent-model’s Details view.

For reference ArticleViewModel has a collection of CommentsViewModel so there is a OTM relationship.

Details View

@model ArticleViewModel

// Renders the Article and its Comments - no forms, just display markup
// A nested _Comments partial is used to render the article's comments.
@Html.Partial("_Article", Model)

// Renders HTML and Javascript for the Pagedown editor - POST form inside.
@Html.Partial("_CommentEditor", new CommentViewModel())

@section scripts { /* code here for validation and the javascript editor */ }

_CommentEditor Partial View

@model CommentViewModel

@using (Html.BeginForm("Comment","Article",FormMethod.Post)) {
    @Html.TextAreaFor(m => m.Content)
    <input type="submit" value="Submit" />
    <input type="reset" value="Clear" />    
}

Article Controller

public ActionResult Details(string slug) {
    return View(_articleService.Get(slug));
}

[HttpPost]
public ActionResult Comment(string slug, CommentViewModel comment) {
    if(ModelState.IsValid) {
        _articleService.AddComment(comment, slug);
    }
    return RedirectToAction("Details", new { Slug = slug });
}

Scenario / Issue

  1. Http Request for /Article/Details/{slug} renders the article, its comments, and the editor form correctly.

  2. The editor works as intended, but on clicking Submit, I noticed the Details action on my controller being called rather than the HttpPost Comment action.

As you can see the Razor Form helper specifies the Comment action on the Article controller using POST.

Question

Why is this happening? What am I missing?

  • 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-29T06:55:46+00:00Added an answer on May 29, 2026 at 6:55 am

    Chump Award!

    The answer is Routing.

    Looking closer with Fiddler, I was actually sending a POST request to /article/comment, so I checked my routing… how I missed this, I don’t know:

    routes.MapRoute("Article-Create", "article/create", new { controller = "Article", action = "Create" });
    routes.MapRoute("Article-Edit", "article/edit/{slug}", new { controller = "Article", action = "Edit" });
    routes.MapRoute("Article-Delete", "article/delete/{slug}", new { controller = "Article", action = "Delete" });
    routes.MapRoute("Article", "article/{slug}", new { controller = "Article", action = "Details" });
    routes.MapRoute("Articles", "articles", new { controller = "Article", action = "Index" });
    

    There is no explicit route for the Comment action. There is a catch-all REST-ish route for fetching an article (article/{slug}). So the Comment POST was being handled by it before hitting the default route…

    My specific solution (i like explicit routing – even when it gets me in trouble) was to add a route for comments, just about the catch-all article/{slug} pattern:

    routes.MapRoute("Article-Comment", "article/comment", new { controller = "Article", action = "Comment" });
    

    Problem solved. Embarrassing.

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

Sidebar

Related Questions

Bear with me, I'm still new to QT and am having trouble wrapping my
Bear with me if this is unclear; I have trouble fully wrapping my head
Bear with me as I try to describe my problem. I have auto-aligned the
Bear with me as I dump the following simplified code: (I will describe the
Please bear with me on this one. I am first going to describe an
I'm having a difficult time expressing this problem, so bear with me and please
I'm not sure how best to describe this, or the best title, so bear
Bear with me on this one. I have an iphone application. It is a
I'm a newbie so bear with me. I'm making a little forum for fun.
So this one is a bit odd to describe, please bear with me :)

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.