0

I am redirecting to another page with Id as a parameter. I passed Id successfully by using RedirectToAction but the controller action method is not accepting id and giving it null always even when there is Id in the url

Code to Redirect to that page

   return RedirectToAction("myaction", new System.Web.Routing.RouteValueDictionary(
                    new { controller = "mycontroller", action = "myaction", Id = 1 }));

Url looks like this

  http://localhost:1234/mycontroller/myaction/1

The Action looks llike this

  [HttpGet]
  public ActionResult myaction(int? Id)
  {
      // ID is null here 
  }
syed mohsin
  • 2,948
  • 2
  • 23
  • 47

1 Answers1

1

Try this once

return RedirectToAction("myaction", "mycontroller", new {Id = 1} ); 

or

return RedirectToAction("myaction", "mycontroller", 
       new System.Web.Routing.RouteValueDictionary( new { Id = 1 }));
Satpal
  • 132,252
  • 13
  • 159
  • 168