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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:21:07+00:00 2026-05-26T18:21:07+00:00

Let’s say I had a fresh MVC site and I wanted to implement URLs

  • 0

Let’s say I had a fresh MVC site and I wanted to implement URLs in the following manner. What are some thoughts on the best way to do this from a routing perspective? I would be storing posts in a basic database table. I would want to keep it as simple as possible from a controller/action perspective.

/2011/ (all posts from 2011)

/2011/11/ (all posts from November 2011)

/2011/11/07 (all posts from November 7th 2011)

/2011/11/07/exact-post-title

/exact-post-title

/about

/archive

/tag/whatever-tag

  • 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-26T18:21:07+00:00Added an answer on May 26, 2026 at 6:21 pm
    // matches /2011/11/07/exact-post-title
    routes.MapRoute(
        "ArticleDetails",
        "{yyyy}/{mm}/{dd}/{title}",
        new { controller = "Articles", action = "Details",
        new { yyyy = @"(19|20)\d\d.", mm = @"\d\d", dd = @"\d\d" }
    );
    
    // matches /2011/11/07
    routes.MapRoute(
        "ArticlesByDay",
        "{yyyy}/{mm}/{dd}",
        new { controller = "Articles", action = "ByDay",
        new { yyyy = @"(19|20)\d\d.", mm = @"\d\d", dd = @"\d\d" }
    );
    
    // matches /2011/11
    routes.MapRoute(
        "ArticlesByMonth",
        "{yyyy}/{mm}",
        new { controller = "Articles", action = "ByMonth",
        new { yyyy = @"(19|20)\d\d.", mm = @"\d\d" }
    );
    
    // matches /2011
    routes.MapRoute(
        "ArticlesByYear",
        "{yyyy}",
        new { controller = "Articles", action = "ByYear",
        new { yyyy = @"(19|20)\d\d." }
    );
    

    There is sort of a problem with the /exact-post-title route. That is going to match pretty much anything you send it. You would have to put every other possible route in front of that one in order to fix that. You could also just prefix all of these routes with /blog or /articles to fix it:

    routes.MapRoute(
        "ExactPostTitle",
        "articles/{title}", 
        new { controller = "Articles", action = "Details" }
    );
    

    Now it won’t conflict with the following:

    routes.MapRoute(
        "About",
        "about",
        new { controller = "Home", action = "About" }
    );
    

    Archive would be similar:

    routes.MapRoute(
        "Archive",
        "archive",
        new { controller = "Home", action = "Archive" }
    );
    

    And finally the Tag route:

    routes.MapRoute(
        "Tag",
        "tag/{tagtext}",
        new { controller = "Tag", action = "Index" }
    );
    

    You might have to play around with the order of the routes, but in general you always want the most specific routes first.

    If you had the following routes:

    routes.MapRoute(
        "ExactTitle",
        "{title}",
        new { controller = "Articles", action = "Details" }
    );
    
    routes.MapRoute(
        "About",
        "about",
        new { controller = "Home", action = "About" }
    );
    

    The first route matches /about so you are going to run into problems if they are in that order.

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

Sidebar

Related Questions

Let's say i have this block of code, <div id=id1> This is some text
Let's say I have the following models class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model):
Let's say for example i have URL containing the following percent encoded character :
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say there is a graph and some set of functions like: create-node ::
Let's say after I had login I will be prompt to enter the Name
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say i have a mysql database table 'article' with the following fields: id
Let's say I have the string: hello world; some random text; foo; How could
Let's say I have table with column 'URL' whrere I store urls like this

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.