0

In a view, if I use

@Url.RouteUrl(MVC.Home.Actions.Foo())

where MVC.Home.Actions.Foo() is an ActionResult generated by T4MVC,

then I expect to get /foo (which is what I've defined via attribute routing)

but I actually get /foo?RouteValueDictionary=System.Web.Routing.RouteValueDictionary

How do I get the url that I want?

Incidentally, the action is as follows:

[HttpPost]
[Route("foo")]
public virtual ActionResult Foo(string bar) { /* ... */ }
h bob
  • 3,610
  • 3
  • 35
  • 51
  • Could you show your action declaration (`MVC.Home.Actions.Foo()`) with AttributeRouting decoration? – b2zw2a Nov 26 '14 at 07:18
  • @plentysmart I've edited the question accordingly – h bob Nov 26 '14 at 10:23
  • `@Url.RouteUrl("foo")` should be sufficient –  Nov 26 '14 at 12:20
  • @StephenMuecke That gives me "A route named 'foo' could not be found in the route collection" – h bob Nov 26 '14 at 12:24
  • I've decided to use `@Url.Action(MVC.Home.Actions.Foo())` which gives me the desired result. But my original question still holds, not sure how to solve it. – h bob Nov 26 '14 at 12:28
  • @hbob, Sorry, you would need to add the `RouteName = "foo"` to the attribute –  Nov 26 '14 at 12:32
  • @StephenMuecke Nope that just returns "/?...etc." which is worse than before. It seems `Route("foo")` works though. – h bob Nov 26 '14 at 12:55

0 Answers0