Questions tagged [routevalues]
50 questions
20
votes
5 answers
How do I create the correct route values for this ActionLink?
The Model of SearchResults.aspx is an instance of PersonSearch; when the request for a new page arrive (a GET request), the action method should take it and compute the new results.
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult…

gremo
- 47,186
- 75
- 257
- 421
19
votes
5 answers
MVC ActionLink add all (optional) parameters from current url
The very famous ActionLink:
<%: Html.ActionLink("Back to List", "Index")%>
Now, this link is in my Details view. The Index view is a search page. The URL of that looks like this:…

Stefanvds
- 5,868
- 5
- 48
- 72
8
votes
2 answers
How to parse a string URL into MVC Route Values (area, controller, action, querystring)?
Is there a method to extract the area, controller, action, and querystring from a URL in ASP.NET MVC? Don't want to reinvent the wheel implementing my own if there's already a way to do it.
Thanks!

Ozzie Perez
- 583
- 2
- 8
- 17
8
votes
5 answers
Pass Dictionary of routeValues to ActionLink
All,
Getting to grips with ASP.NET MVC. So far, so good, but this one is a little nuts.
I have a view model that contains a dictionary of attributes for a hyperlink, used like this:
menu = model variable
Html.ActionLink(Html.Encode(menu.Name),…

Graham
- 413
- 3
- 6
- 10
7
votes
3 answers
How to pass routeValues that contains hyphen via actionlink in asp.net mvc 5
I have an actionlink in view, I need it to pass parameter containing hyphen (-). Changing the name convention is not possible. How do I do this?
@Html.ActionLink("abc", "abc", "abc", new { area = "",sap-ie="Edge" }, new { id =…

Daniel W
- 1,092
- 1
- 12
- 25
7
votes
1 answer
Use RedirectToAction without passing query string parameters/route values
I have a "Thingy" controller for that looks like:
[HttpPost]
public ActionResult DeleteConfirmed(long? id) {
//
return RedirectToAction("Index", "Thingy");
}
However, RedirectToAction keeps having…

Kaganar
- 6,540
- 2
- 26
- 59
5
votes
2 answers
ActionLink route values containing specific characters
I am using this action-link to send a route value id to controller but my id value like this config.xml
and here is my action-link
@Html.ActionLink("Destroy", "DeleteFile", "Files", new { id = "config.xml"})
The question is when I want to click…

Younis Qadir
- 315
- 1
- 4
- 16
5
votes
1 answer
MVC dynamic routeValues for ActionLinks
I have a need to use ActionLink to link to ann edit screen for my ViewModel A.
A has a composite key, so to link to it, the route values will have to have 3 pramaters, like this:
<%: Html.ActionLink("EDIT", "Action", "Controller",
new { area =…

getit
- 623
- 2
- 8
- 30
5
votes
3 answers
What C# feature allows the use of an "object literal" type notation?
I'm coming from JavaScript, and I know that { } is an object literal, not needing to require the new Object call; I'm wondering if it's the same with C# in the {"id",id}, {"saveChangesError",true} part.
I know there are two C# features in here, care…

Jan Carlo Viray
- 11,856
- 11
- 42
- 63
4
votes
2 answers
RouteValueDictionary/object problem in mvc ActionLink
so here it goes:
I have a html helper which renders ActionLinks with the optional parameters of the current url in it. this html helper also lets you add some more optional parameters as you please and merges them in 1 RouteValueDictionary.
…

Stefanvds
- 5,868
- 5
- 48
- 72
4
votes
1 answer
Route Parameters not working in WebApi
Below is WebAPI.
[RoutePrefix("api/customer")]
public class CustomerController : ApiController
{
[Route("{id:int:min(1)}/")]
public HttpResponseMessage Get(int id)
{
//my stuff
}
}
If I pass any value less than 1 (say 0 or…

Kgn-web
- 7,047
- 24
- 95
- 161
4
votes
2 answers
Querystring formatting in asp.net MVC 2
Seems like a straitforward question but I can't quite figure it out myself...
I have an actionlink like so
Html.ActionLink( "Test", "test", new { q = "search+twitter" } )
This produces a url string as…

Stuart
- 671
- 7
- 20
4
votes
2 answers
Are there conflict between RouteValueDictionary and htmlAttributes?
I am using a RouteValueDictionary to pass RouteValues to a ActionLink:
If I code:
<%:Html.ActionLink(SharedResources.Shared_Pagination_First, Model.ActionToExecute, Model.ControllerToExecute, Model.FirstRouteValues, null)%>
The link result is…

Pedre
- 446
- 1
- 8
- 16
3
votes
1 answer
Adding dynamic parameters with Html.BeginForm and jQuery submit
// html
<% using (Html.BeginForm("MyAction", "MyController",
new { id = ViewContext.RouteData.Values["id"] },
FormMethod.Post,
new { enctype = "multipart/form-data", class="myForm" }))
{…

fearofawhackplanet
- 52,166
- 53
- 160
- 253
3
votes
4 answers
How to work with RouteValues with multiple values of the same name
In my ASP.NET MVC 4 application I can filter on multiple tags. In HTML, it looks like this:

doekman
- 18,750
- 20
- 65
- 86