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 1041687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:23:29+00:00 2026-05-16T15:23:29+00:00

To support legacy URLs in my application, I use a regex to convert URLs

  • 0

To support legacy URLs in my application, I use a regex to convert URLs of the form /Repo/{ixRepo}/{sSlug}/{sAction} to the new form /Repo/{sName}/{sAction}, using the ixRepo to get the correct sName. This works well, and I can redirect the user to the new URL with a RedirectResult.

However, I’d like to catch legacy URLs with an invalid action before I redirect the user. How can I verify if a URL string will map to a registered route? MVC clearly does this internally to map a request to the correct action, but I’d like to do it by hand.

So far, I’ve come up with this:

var rd = Url.RouteCollection.GetRouteData(new HttpContextWrapper(new HttpContext(
    new HttpRequest("", newPath, ""),
    new HttpResponse(null))));

which appears to always return a System.Web.Routing.RouteData, even for bad routes. I can’t find a way to check if the route was accepted as a catch all, or if actually mapping to a route that’s registered on the controller.

How can I use MVC’s routing system to check if a URL maps to a valid controller/action via a registered route?

(I’ve seen ASP.NET MVC – Verify the Existence of a Route, but that’s really inelegant. MVC has a routing system built in, and I’d like to use that.)

  • 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-16T15:23:29+00:00Added an answer on May 16, 2026 at 3:23 pm

    Wrong question. Anything can be a route, whether or not it actually maps to an action.

    I think you’re asking, “Will this execute OK, or will it 404?” That’s a different question.

    For that, you need to do what MVC does. Look in the MVC source at MvcHandler.ProcessRequestInit and then ControllerActionInvoker.InvokeAction to see how MVC looks up the controller and action, respectively.

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

Sidebar

Related Questions

To add support for some new features in a VB3.0 legacy application, I need
I support a legacy Java application that uses flat files (plain text) for persistence.
I've inheirited support for a legacy web app which is directly using the **.internal.**
I'm writing a new version of an API and would like to support legacy
In order to support a legacy application that's in the field, I need my
Initially, I thought I could use :first-letter in CSS, legacy browser support aside, but
Brief history: I'm writing a stored procedure to support a legacy reporting system (using
In support of some legacy code, I have to read a text file and
My team and support a large number of legacy applications all of which are
I'm creating a custom control in C# for a legacy application which only supports

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.