T4MVC Optional Parameter Inferred From Current Context
Posted
by
Itakou
on Stack Overflow
See other posts from Stack Overflow
or by Itakou
Published on 2012-10-15T21:25:57Z
Indexed on
2012/10/15
21:37 UTC
Read the original article
Hit count: 198
I have read the other post about this at T4MVC OptionalParameter values implied from current context and I am using the latest T4MVC (2.11.1) which is suppose to have the fix in. I even checked checked to make sure that it's there -- and it is.
I am still getting the optional parameters filled in based on the current context.
For example: Let's say I have a list that is by default ordered by a person's last name. I have the option to order by first name instead with the URL
http://localhost/list/stuff?orderby=firstname
When I am in that page, I want to go back to order by first name with the code:
@Html.ActionLink("order by last name", MVC.List.Stuff(null))
the link I wanted was simply
http://localhost/list/stuff
without any parameters to keep the URL simple and short - invoking default behaviors within the action. But instead the orderby is kept and the url is still
http://localhost/list/stuff?orderby=firstname
Any help would be great. I know that in the most general cases, this does remove the query parameter - maybe I do have a specific case where it was not removed. I find that it only happens when I have the URL inside a page that I included with RenderPartial.
My actual code is
<li>@Html.ActionLink("Recently Updated", MVC.Network.Ticket.List(Model.UI.AccountId, "LastModifiedDate", null, null, null, null, null))</li>
<li>@Html.ActionLink("Recently Created", MVC.Network.Ticket.List(Model.UI.AccountId, "CreatedDate", null, null, null, null, null))</li>
<li>@Html.ActionLink("Most Severe", MVC.Network.Ticket.List(Model.UI.AccountId, "MostSevere", null, null, null, null, null))</li>
<li>@Html.ActionLink("Previously Closed", MVC.Network.Ticket.List(Model.UI.AccountId, "LastModifiedDate", null, "Closed", null, null, null))</li>
the problem happens when someone clicks Previously Closed and and go to ?status=closed. When they click Recently Updated, which I want to the ?status so that it shows the active ones, the ?status=closed stays.
Any insight would be greatly appreciated.
© Stack Overflow or respective owner