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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:25:26+00:00 2026-05-16T23:25:26+00:00

today I’ve got some interesting observation, that I need to explain. I’ve got my

  • 0

today I’ve got some interesting observation, that I need to explain. I’ve got my Person class that is described as above:

public class Person
{
   public int Id { get; set; }
   public string FirstName { get; set; }
   public string LastName { get; set; }
}

now in my MVC2 application I’ve got PersonController with following edit metod:

public ActionResult Edit(int id)
{
    var permission = _service.GetPerson(id);
    return View(person);
}

[HttpPost]
public ActionResult Edit(Person person)
{
    if (ModelState.IsValid)
    {
        _service.UpdatePerson(permission);
        return RedirectToAction("Index");
    }

    return View(person);
}

Now on my Edit.aspx view I have form that contains only FirstName and LastName, but what suprise me when the post is done in my controller the Person object have an Id setted correctly (which was not part of a form).

Now I guess that it’s taken from the rout value of an id parameter, that is send in my action address, but is it save? I mean.. It’s nice that I do not have to put hidden field for id, but is there any danger caused by mixing get and post parameters in mvc2?

And one more concern. What if I do put hidden for id. Then it will be sent both ways (get and post), so then.. which id will be used?

  • 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-16T23:25:27+00:00Added an answer on May 16, 2026 at 11:25 pm

    Yes it is taken from the route. It is dangerous because if you rename this property on the Person class your code might break. Also if you change the route the same might happen.

    And to answer your second question. Assume the following form:

    <form action="/home/edit/5" method="post">
        <input type="text" name="Id" value="1" />
        <input type="submit" value="Go" />
    </form>
    

    In this case the Id will be taken from the POST request and not the route.

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

Sidebar

Related Questions

Today when I was in computer organization class, teacher talked about something interesting to
Today I discovered that my fresh installation of Apache HTTP Server is able to
Today at work we came across the following code (some of you might recognize
Today somebody told me that interface implementation in C# is just Can-Do relationship, not
Today, I ran into this weird problem with a user using Mac OS X.
Today I was listening to the Hanselminutes show about .NET 3.5 SP1...What's inside ,
Today I was working on a tab navigation for a webpage. I tried the
Today I had a coworker suggest I refactor my code to use a label
Today I stumbled about a Problem which seems to be a bug in the
Today I had a discussion with a colleague about nested functions in Javascript: function

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.