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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:07:23+00:00 2026-06-11T11:07:23+00:00

I have the following model: public class Person { public int ID{get;set;} public string

  • 0

I have the following model:

public class Person
{
    public int ID{get;set;}
    public string Name {get;set;}
    public string Address{get;set;}
}

For other hand i have the following view called Index:

@model List<Person>
@{

   foreach(Person person in Model)
   {
     <a href="#" id="@person.ID">@person.Name</a>
   }
}

Finally i have the following action:

public ActionResult Index()
{
     List<Person> persons=new List<Person>();
     persons.Add(new Person(){ID=1,Name="John"});
     persons.Add(new Person(){ID=2,Name="Tom"});
     persons.Add(new Person(){ID=2,Name="Derek"});
}

Im thinking to create a form (since i cannot use ajax for this app due to some requirements), to post an instance of the person chosen by the user (when clicks an anchor of my view). I would like to know how i could post a Person instance to another action described below (since my view is typed to a generic list of persons).

[HttpPost]
public ActionResult Index(Person person)
{
     ... Do whatever
}
  • 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-06-11T11:07:24+00:00Added an answer on June 11, 2026 at 11:07 am

    Solution with POST:

    in order to work it with POST you will have to palce a form and plant hidden fields like

    @model List<Person>
    @{
    
       foreach(Person person in Model)
       { 
         <form action="/controller/actionresult">
         <input type="submit" value=person.Name />
         <input type="hidden" name="ID" value="@person.ID"
         <input type="hidden" name="Name" value="@person.Name"
         </form>
       }
    }
    

    and on the server side

    [HttpPost]
    public ActionResult Index(Person person)
    {
         ... Do whatever
    }
    

    Solution with GET:

    a tags normally dont work with POST there default behaviour is to request the server for a resource via GET although you can override this behaviour using javascript but in your case that is not an option therefore you can try

    @model List<Person>
        @{
    
           foreach(Person person in Model)
           {
             @Html.ActionLink(persno.Name,"Index","home",new{ID=person.ID,Name=person.Name,null);      
           }
        }
    

    the only drawback is you will have to use a submit button instead of a tags, you can use css styling to style the button like an a tag. also if you have not set custom routes for this kind of request the uri will have query string params like

    http://yourdomain/home/index?ID=1&Name=john
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Model: public class Person { public string Name {get;set;} public
I have the following model: public class Person { public string Name { get;
So I have the following model: public class Person { public String FirstName {
I have the following model, view and controller. Model public class Person { public
I have the following model: public class Tag { public int Id { get;
I have the following Model: public class DeliveryTracking { public string TrackingRef { get;
Given the classes: public class Person { public string Name { get; set; }
I have following model: public class FormularModel { [Required] public string Position { get;
I have the following model: public class Product { public int Id { get;
I have the following model public class UserViewModel { public String CVR_Nummer { get;

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.