- @Html.RouteLink("Edit", "PageWithId",
- new
- {
- controller = "Customers",
- action = "Edit",
- id = item.CustomerID,
- page = ViewBag.CurrentPage
- })
- routes.MapRoute(
- name: "PageWithId",
- url: "{controller}/{action}/{page}/{id}",
- defaults: new { controller = "Customers", action = "Edit", page = UrlParameter.Optional, id = UrlParameter.Optional }
- );
- routes.MapRoute(
- name: "PageWithSort",
- url: "{controller}/{action}/{page}/{SortColumn}/{CurrentSort}",
- defaults: new { action = "Index", page = UrlParameter.Optional, SortColumn = UrlParameter.Optional, CurrentSort = UrlParameter.Optional }
- );
- routes.MapRoute(
- name: "PageWithId",
- url: "{controller}/{action}/{page}/{id}",
- defaults: new { controller = "Customers", action = "Edit", page = UrlParameter.Optional, id = UrlParameter.Optional }
- );
- routes.MapRoute(
- name: "Default",
- url: "{controller}/{action}/{id}",
- defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
- );
when i click on the link the Edit action is getting called but customer id is getting null where as ALFKI is there in url as customer id.
here is my edit action details
- public ActionResult Edit(string id, int page)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Customer customer = db.Customers.Find(id);
- if (customer == null)
- {
- return HttpNotFound();
- }
- ViewBag.CurrentPage = page;
- return View(customer);
- }
thanks
Srikant MaruwadaPosted Feb 6, 2018, 12:22 AM