Send value from controller to controller

Cucko

I have two controllers, each with a Save method.

public ActionResult SaveContract(Contract contract)
        {
          //code shortened for brevity
          int id = Convert.ToInt32(cmd.Parameters["@OBJECTID"].Value);
          return RedirectToAction("SaveContractDetails", "ContractDetails", id);
        }

and I am redirecting to SaveContractDetails method in ContractDetails controller. What I am trying to do is send the id of the Contract model to the SaveContractDetails method in the ContractDetails controller, like so:

public IActionResult SaveContractDetails(ContractSettlementDetail contractSettlementDetail, int id)
        {
          return View();
        }

The thing is, the id in the SaveContractDetails method is 0. I suppose I can't send it the way I am trying to. I'd really want to avoid catching the id with javascript somehow and sending it to the method with an ajax. How should I proceed, any advice for this intern?

Munesh Kumar

Just send your route values this way => new { id = id } and it will work

public ActionResult SaveContract(Contract contract)
        {
          int id = Convert.ToInt32(cmd.Parameters["@OBJECTID"].Value);
          return RedirectToAction("SaveContractDetails", "ContractDetails", new { id = id });
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to send value from view to controller?

From Dev

Laravel send value from dropdown list to controller

From Dev

Send a value to controller via a widget?

From Dev

Can I send value from javascript to angular controller at runtime

From Dev

send value from Angular service App to C# backend controller

From Dev

how to send value from thymyleaf to controller which is not used in view

From Dev

How to send value of variable from controller to config function?

From Java

Send the response as key value pair from Spring controller?

From Dev

GET request from a jsp to controller and send a string value with action

From Dev

How to send/return data/value from CI_Controller to AJAX

From Dev

How to send value from controller of Laravel to Vue.js?

From Dev

Send post from view to controller

From Dev

Send data from .gsp to controller

From Dev

Send A varriable from controller to blade

From Dev

Send data from controller to directive

From Dev

Send data from service to controller

From Dev

Passing value from one controller to another controller

From Dev

Send button value with Ajax to Controller in .net core

From Dev

MVC send value string controller to view

From Dev

Using Ajax to send html value to Flask controller

From Dev

How to send data from one controller to another controller in angularjs

From Dev

How to send data from child controller to Parent controller in AngularJS?

From Dev

How to send data from angularjs controller to server(nodejs) controller in meanjs

From Dev

How to send data from controller to another controller in yii2

From Dev

Can I send ViewBag from controller to anther Controller in MVC?

From Dev

In codeigniter i am send a php variable from view page to controller through the <a> tag, but i can't display value in controller page

From Dev

Access the scope value from the controller

From Dev

sending value from view to controller

From Dev

Pass a value from a controller to directive

Related Related

  1. 1

    How to send value from view to controller?

  2. 2

    Laravel send value from dropdown list to controller

  3. 3

    Send a value to controller via a widget?

  4. 4

    Can I send value from javascript to angular controller at runtime

  5. 5

    send value from Angular service App to C# backend controller

  6. 6

    how to send value from thymyleaf to controller which is not used in view

  7. 7

    How to send value of variable from controller to config function?

  8. 8

    Send the response as key value pair from Spring controller?

  9. 9

    GET request from a jsp to controller and send a string value with action

  10. 10

    How to send/return data/value from CI_Controller to AJAX

  11. 11

    How to send value from controller of Laravel to Vue.js?

  12. 12

    Send post from view to controller

  13. 13

    Send data from .gsp to controller

  14. 14

    Send A varriable from controller to blade

  15. 15

    Send data from controller to directive

  16. 16

    Send data from service to controller

  17. 17

    Passing value from one controller to another controller

  18. 18

    Send button value with Ajax to Controller in .net core

  19. 19

    MVC send value string controller to view

  20. 20

    Using Ajax to send html value to Flask controller

  21. 21

    How to send data from one controller to another controller in angularjs

  22. 22

    How to send data from child controller to Parent controller in AngularJS?

  23. 23

    How to send data from angularjs controller to server(nodejs) controller in meanjs

  24. 24

    How to send data from controller to another controller in yii2

  25. 25

    Can I send ViewBag from controller to anther Controller in MVC?

  26. 26

    In codeigniter i am send a php variable from view page to controller through the <a> tag, but i can't display value in controller page

  27. 27

    Access the scope value from the controller

  28. 28

    sending value from view to controller

  29. 29

    Pass a value from a controller to directive

HotTag

Archive