MVC MapPageRoute and ActionLink

Posted by Dismissile on Stack Overflow See other posts from Stack Overflow or by Dismissile
Published on 2010-12-14T16:06:46Z Indexed on 2010/12/31 15:54 UTC
Read the original article Hit count: 327

I have created a page route so I can integrate my MVC application with a few WebForms pages that exist in my project:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // register the report routes
    routes.MapPageRoute("ReportTest",
        "reports/test",
        "~/WebForms/Test.aspx"
    );

    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
    );
}

This has created a problem whenever I use Html.ActionLink in my Views:

<%: Html.ActionLink("Home", "Index", "Home") %>

When I load the page in the browser the link appears like:

http://localhost:12345/reports/test?action=Index&controller=Home

Has anyone run into this before? How can I fix this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc