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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:04:14+00:00 2026-05-24T17:04:14+00:00

I need to have two arguments in action method: one for id of article

  • 0

I need to have two arguments in action method: one for id of article and second with model of comment.

I wrote form in article which have action Articles/{id}/AddComment.

        routes.MapRoute(
            "Article_action", // Route name
            "Articles/{id}/{action}", // URL with parameters
            new { controller = "Articles" } // Parameter defaults
        );

My form:

<form action="@Url.RouteUrl( new { controller = "Articles", id = article.article_id, action = "AddComment" })" method="post">
<input type="hidden" name="article_id" value="@article.article_id" />
<textarea name="comment" rows="6" cols="30"></textarea>
<input type="submit" />
</form>

Here is my ArticleViewModelResponse:

public class ArticleViewModelResponse {
    public int article_id{set;get;}
    public string comment{set;get;}
}

My action method:

[HttpPost]
public ActionResult DodajKomentarz( int id, ArticleViewModelResponse comment) {
//...
}

Here is a problem… comment argument always has null value but id is correct. And if I change type ArticleViewModelResponse to FormCollection then comment has every variables.

Where is the problem? Why FormCollection has evethings and ArticleViewModelResponse doesnt?

P.S. Of course this is only example demonstrates my problem and it isnt all my code. So ignore every misspeling.

  • 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-24T17:04:15+00:00Added an answer on May 24, 2026 at 5:04 pm

    It looks the names of your input elements are wrong, you need to prefix them with the parameters name, try this:

    <input type="hidden" name="comment.article_id" value="@article.article_id" />
    <textarea name="comment.comment" rows="6" cols="30"></textarea>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two functions, one which parses all the arguments sent to the function
in php i wrote my own debug function which have two arguments: text and
I have need for a function pointer that takes two arguments and returns a
I need to have two UITableViews on one UIView. I can make it work
I have two unsorted lists and I need to produce another list which is
I need to run a function that takes two arguments several times. I have
I have a C program in which two scanf() are done. I need to
I have a class which takes two arguments on it's constructor, an int and
I have a barButtonItem that calls an action which swaps two views in an
I have two shell scripts. One script dynamically creates the call to the second

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.