Search code examples
c#asp.net-mvcactionlink

why html action link does not pass the null Id value when use an id


I have used an html action link below

 @Html.ActionLink("Book Now", "EnquiryForCruise", "Cruise", new { sid = "stackoverflow" })

it navigate to correct controller action result but with null id value path is localhost:15777/Cruise/EnquiryForCruise?Length=6

my controller is below

  public ActionResult EnquiryForCruise(string sid)
  {

     return View();
  }
//in here id value is null

I have worked with this before and those worked fine. I don't have idea why is this.hope your help.


Solution

  • Please try this :

    @Html.ActionLink("Book Now", "EnquiryForCruise", "Cruise", new { sid = "stackoverflow" }, null)