Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Error: No route in the route table matches the supplied values when using Html.Action or Html.RenderAction in Asp.Net MVC April 6, 2010

Filed under: Asp.Net,Error,Web — Rupert Bates @ 4:20 pm

I ran across this error today when using the new Html.Action:

System.InvalidOperationException: No route in the route table matches the supplied values.

It turns out that Action and RenderAction require there to be a default route to catch the {controller}/{action} pattern.

So adding this into the RegisterRoutes method fixed the problem:

routes.MapRoute(
                "DefaultAction",
                "{controller}/{action}",
                new
                {
                    controller = "Home",
                    action = "Index"
                }
                );
Advertisements
 

3 Responses to “Error: No route in the route table matches the supplied values when using Html.Action or Html.RenderAction in Asp.Net MVC”

  1. […] to VoteError: No route in the route table matches the supplied values when… (4/6/2010)Tuesday, April 06, 2010 from eliasbland.wordpress.comIt turns out that Action and RenderAction […]

  2. […] It is important that your action takes the context as a parameter or it will only be called once the first time the page is hit and then get cached along with everything else. It is also important that you have a route in your route table that will catch the {controller}/{action} url pattern. See this post for more details. […]

  3. Ilia Says:

    Try check all followed ActionResult redirects and requests from your Action, that couse error.
    In my case it helped.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s