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

  • Home
  • SEARCH
  • 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 8337033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:10:16+00:00 2026-06-09T04:10:16+00:00

For a project I’ve to(unfortunately) match some exact url. So I thought it will

  • 0

For a project I’ve to(unfortunately) match some exact url.

So I thought it will not be a problem, I can use the “MapRoute”, to match urls with the desired controller. But I can’t make it work.

I’ve to map this URL:

http://{Host}/opc/public-documents/index.html

to

Area: opc
Controller: Documents
Action: Index

Another example is to map

http://{Host}/opc/public-documents/{year}/index.html

to

Area: opc
Controller: Documents
Action:DisplayByYear
Year(Parameter): {year}

I tried this, whitout success, in my area(ocpAreaRegistration.cs):

context.MapRoute("DocumentsIndex", "opc/public-documents/index.html", 
    new {area="opc", controller = "Documents", action = "Index"});
context.MapRoute("DocumentsDisplayByYear", "opc/public-documents/{year}/index.html", 
    new {area="opc", controller = "Documents", action = "Action:DisplayByYear"});

But I got some 404 Errors 🙁 when I’m trying to access it. What am I doing wrong?

  • 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-06-09T04:10:20+00:00Added an answer on June 9, 2026 at 4:10 am

    I’m not sure why you need to do this (I can only assume you’re coming from a legacy application), but this is working for me:

    opcAreaRegistration.cs:

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "opc_public_year_docs",
            "opc/public-documents/{year}/index.html",
            new { controller = "Documents", action = "DisplayByYear" }
        );
    
        context.MapRoute(
            "opc_public_docs",
            "opc/public-documents/index.html",
            new { controller = "Documents", action = "Index" }
        );
    
        context.MapRoute(
            "opc_default",
            "opc/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );
    }
    

    Controller:

    public class DocumentsController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    
        public ActionResult DisplayByYear(int year)
        {
            return View(year);
        }
    }
    

    Make sure you put those routes in the area routing file rather than global.asax and you should be good to go.

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

Sidebar

Related Questions

My project has some references. One of them has no path. I can't view
Project#1 has some interfaces and classes that project#2 references. Now I want to use
Project was running fine, i made a change some where and couldn't figure out
Project Requirements: I need to build a web service that will receive chunks of
Project Euler I have recently begun to solve some of the Project Euler riddles.
Project Euler has a paging file problem (though it's disguised in other words). I
Project Euler problem 36 states: The decimal number, 585 = 1001001001 (binary), is palindromic
Project: Winforms, .NET framework: 3.5 (Visual Studio 2008) My problem is: I have a
The project i am working at right now requires some declarative way of defining
Project type: Asp MVC 2/NHibernate/C# Problem If you have an edit page in an

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.