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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:26:19+00:00 2026-05-28T14:26:19+00:00

I implemented two actions : The first action it renders Address view with consumer

  • 0

I implemented two actions :

The first action it renders Address view with consumer ID within URL :

This is the URL http://localhost:90/Consumer/Address?id=18755

[HttpGet]
public ActionResult Address(int id)
{
return View();
}

The second action it posts the Address form :

 [HttpPost]
public ActionResult Address(FormCollection value)
{
  int id = Convert.ToInt32(Request["id"]);
  // Some code ... 
  return View();
}

When I fire save action I found ID is null, I would like to retrieve conusmer ID from Get action ?

  • 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-28T14:26:20+00:00Added an answer on May 28, 2026 at 2:26 pm

    I would like to retrieve conusmer ID from Get action ?

    You cannot retrieve it from the GET action because you are now executing the POST action. So you will have to post this parameter if you want to be able to retrieve it.

    So for example if we suppose that your GET action rendered a view containing a <form> that will be used to POST you could include the id as a hidden field inside this form. This way when the form is submitted it will be sent to the second action:

    @using (Html.BeginForm())
    {
        @Html.Hidden("id", Request["id"])
    
        ... some other input fields
        <button type="submit">OK</button>
    }
    

    Also in your POST action instead of doing some manual type conversions simply use the default model binder to do that for you. Define a view model:

    public class MyViewModel
    {
        public int Id { get; set; }
    
        ... some other properties
    }
    

    and then have your POST action take this view model as action argument:

    [HttpPost]
    public ActionResult Address(MyViewModel model)
    {
        int id = model.Id;
        // Some code ... 
    
        return View();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which of the following has the best performance? I have seen method two implemented
I have implemented inheritance for two parent classes called Table and Field . Each
Two function should be implemented, and I am wondering what type of validation I
I implemented a small OOP library in Lua, and two things are not quite
How can the XOR operation (on two 32 bit ints) be implemented using only
I'm currently using two libraries (prototype and jQuery), thus I've implemented the jQuery noConflict
I want to implement a two-pass cache system: The first pass generates a PHP
Two days ago I wrote this question: How can I retrieve an object on
My first question is this although I doubt if it is possible. However, if
I have a button i need two action to be taken place ,that is

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.