I am getting a strange value in quick watch. I need to get the id value which is 222 from the URL. My code in the watch window is Url.RequestContext.RouteData.Values
. My actual URL is http://localhost:50983/Measurement/Create/222
The value I get from the above line of code is
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Customer", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Measurement",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Measurement", action = "Create", id = UrlParameter.Optional }
);
I had an action="Create" due to which I was getting the Id which is an Optional Parameter was set to Create. When I set the action with the value Measurement/Create/222, then I was getting the Id value with 222.
So, I replace the form tag with @Html.BeginForm and pass the route values with the the id.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.