I have the following route:
context.MapRoute
(
"PersonArea_tripleInt",
"PersonArea/{controller}/{action}/{int1}/{int2}/{int3}",
new { controller = "Person", action = "Index" }, new { int1 = new IntConstraint(), int2 = new IntConstraint(), int3 = new IntConstraint() }
);
I'm using in my controller like this:
RoleListUrl = Url.Action("RoleList", "Person", new { Area = "PersonArea" }),
To produce this url: "/PersonArea/Person/RoleList"
In my view, i have drop downs that will fill in the int1, int2, and int3 values. I'm using JavaScript in the client to fill out the rest of the URL:
"/PersonArea/Person/RoleList/12/43/76"
This is working great the first time, but when the page reloads, the old values (12, 43, 76) get re-used when creating the base url in my controller. So, when user interacts with dropdowns the following URL gets created on client:
"/PersonArea/Person/RoleList/12/43/76/88/154/78"
How do I get Url.Action to ignore the old values (12, 43, 76) on subsequent posts to the server so the client can construct the correct url? I'm resorting to hard coding the base url ("/PersonArea/Person/RoleList/") in the controller instead.
I just want the controller to produce "/PersonArea/Person/RoleList" every time and let the client fill in the rest of the parameters.
What am I missing? Thanks.
Try clearing the route values explicitly:
RoleListUrl = Url.Action("RoleList", "Person", new { Area = "PersonArea", int1 = "", int2 = "", int3 = "" }),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With