Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3456140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:41:59+00:00 2026-05-18T09:41:59+00:00

I have a custom routehandler in ASP.NET MVC2 to catch all url’s at a

  • 0

I have a custom routehandler in ASP.NET MVC2 to catch all url’s at a prefixed path like this:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Add(new Route("@api/{*all}", new ApiHandler()));
routes.MapRoute(
  "Default", // Route name
  "{controller}/{action}/{id}", // URL with parameters
  new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

Routing works fine, but if i use Html.Actionlink or return ReturnToAction() from a controller, the uri built creates a broken uri like this:

/@api?action=Add&controller=Home

instead of

/Home/Add

How can i influence the uri building logic to consider the Default route pattern?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:42:00+00:00Added an answer on May 18, 2026 at 9:42 am

    I’ve come up with a hack to stop the described behavior. While this “solves” the problem, it’s really kind of nasty and I’d prefer a cleaner way to exclude a route from the virtual path building logic

    routes.Add(
      new Route("@api/{*all}",
      // A random and unlikely controller name as the default
      new RouteValueDictionary() { { "controller", "qwewqewqeqweq" } },
      // and a constraint requiring any controller to be that random, default value
      new RouteValueDictionary() { { "controller", "qwewqewqeqweq" } }, 
      new ApiHandler()
    );
    

    This means that the route would only be chosen for Virtual Path building if the controller in question was “qwewqewqeqweq”, which hopefully is unlikely. I said it was nasty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If say I have a route that is defined like this: {books}/{*all} , then
I have custom event that has several different subscribers who will all use the
I have custom control with asp textbox inside. And i need to Validate by
I currently have an ASP .NET MVC site that has two domains pointing to
I have custom js/jquery code which is running fine on all browsers including IE9
I have custom assembly that is loaded on runtime. at this point i have
I have custom coded layout to hold all the childs. Here is the code:
i have quite big ASP.NET MVC 2 application (multiple areas, each with own routing
I have custom membership and role provider (C#) in my .net 4 (webform based)
I have custom SPlist with some fields that I'd like to bind to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.