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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:50:17+00:00 2026-06-04T09:50:17+00:00

I have a controller named Raportare that has two actions: ReportA and ReportB .

  • 0

I have a controller named Raportare that has two actions: ReportA and ReportB.
Both return an excel file based on the parameters supplied.

public ActionResult ReportA(int? month, int? year)
{
...
}
public ActionResult ReportB(int? month, int? year)
{
...
}

My global.asax has the following routing rules for this :

routes.MapRoute(
                "ReportA",
                "{Raportare}/{ReportA}/{month}/{year}",
                new { controller = "Raportare", action = "ReportA", month = UrlParameter.Optional, year = UrlParameter.Optional});

 routes.MapRoute(
                "ReportB",
                "{Raportare}/{ReportB}/{month}/{year}",
                new { controller = "Raportare", action = "ReportB", month = UrlParameter.Optional, year = UrlParameter.Optional }); 

However when I go mysite.com/Raportare/ReportB/5/2012 it’s returning the ReportA file.
It works fine if I go to mysite.com/Raportare/ReportB?month=5&year=2012.
Probably I’m doing something wrong in the routing rules but I can’t figure it out.

  • 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-04T09:50:17+00:00Added an answer on June 4, 2026 at 9:50 am

    You don’t need to add a route for every action – they work like templates and the 3rd parameter is just default values.

    routes.MapRoute(
      "reports",
      "Raportare/{action}/{month}/{year}",
      new {
        controller = "Raportare",
        action = "ReportA",
        month = UrlParameter.Optional,
        year = UrlParameter.Optional
      }
    );
    

    Put this before your default rule in Global.asax.cs, otherwise the default might match first.

    Then mysite.com/Raportare/ReportB/5/2012 will invoke the ReportB action because it has been specified in the url.

    mysite.com/Raportare will invoke ReportA, because it is the default action.

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

Sidebar

Related Questions

I have a controller named User. In two of its actions, I would like
I am using the Zend Framework. I have a controller named 'UserController' that has
I have two controller class named TEnterCorrectCodeController and TEmergencyCancelController. In Both the classes there
I have a controller named Content, which has an Index action, which is associated
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
In my application I have controller named Snippets both in default area (in application
Hi I have a controller named places with some actions like view, new, create
I have two functions in controller named step1 and step2. I want to pass
Say that you have a controller named Buildings and that every user in the
I have a controller named store_controller.rb and method index that renders index.html.erb , displaying

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.