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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:05:37+00:00 2026-05-15T06:05:37+00:00

I am creating a modular ASP.NET MVC application using areas. In short, I have

  • 0

I am creating a modular ASP.NET MVC application using areas. In short, I have created a greedy route that captures all routes beginning with {application}/{*catchAll}.

Here is the action:

// get /application/index  
public ActionResult Index(string application, object catchAll)  
{  
  // forward to partial request to return partial view  
  ViewData["partialRequest"] = new PartialRequest(catchAll);  

  // this gets called in the view page and uses a partial request class to return a partial view  
}  

Example:

The Url “/Application/Accounts/LogOn” will then cause the Index action to pass “/Accounts/LogOn” into the PartialRequest, but as a string value.

// partial request constructor  
public PartialRequest(object routeValues)  
{  
  RouteValueDictionary = new RouteValueDictionary(routeValues);  
}  

In this case, the route value dictionary will not return any values for the routeData, whereas if I specify a route in the Index Action:

ViewData["partialRequest"] = new PartialRequest(new { controller = "accounts", action = "logon" });

It works, and the routeData values contains a “controller” key and an “action” key; whereas before, the keys are empty, and therefore the rest of the class wont work.

So my question is, how can I convert the “/Accounts/LogOn” in the catchAll to “new { controller = “accounts”, action = “logon” }”??

If this is not clear, I will explain more! 🙂

Matt

This is the “closest” I have got, but it obviously wont work for complex routes:

// split values into array
var routeParts = catchAll.ToString().Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);  

// feels like a hack
catchAll = new
{
  controller = routeParts[0],
  action = routeParts[1]
}; 
  • 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-15T06:05:38+00:00Added an answer on May 15, 2026 at 6:05 am

    You need to know what part is what in the catchAll parameter. Then you need to parse it yourself (like you are doing in your example or use a regexp). There is no way for the framework to know what part is the controller name and what is the action name and so on, as you haven’t specified that in your route.

    Why do you want to do something like this? There is probably a better way.

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

Sidebar

Related Questions

When creating a web application, and lets say you have a User object denoting
While creating classes in Java I often find myself creating instance-level collections that I
Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?
While creating a file synchronization program in C# I tried to make a method
When creating a criteria in NHibernate I can use Restriction.In() or Restriction.InG() What is
When creating a UserControl in WPF, I find it convenient to give it some
When creating a setup/MSI with Visual Studio is it possible to make a setup

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.