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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:04:59+00:00 2026-06-15T21:04:59+00:00

I have MVC3 application that runs under mono on linux. I have this route:

  • 0

I have MVC3 application that runs under mono on linux.
I have this route:

    routes.MapRoute(
        "search",
        @"search/{term}",
        new {
            controller = MVC.Mobile.Name,
            action = MVC.Mobile.Actions.ActionNames.Search,
            term = UrlParameter.Optional
        },
        new {
            term = @"^[0-9]*$"
        }
    );

which is working fine in windows for both when i show term parameter (e.g. /search/123) or whithout (e.g. /search). Now the problem appears after I deploy it on linux: it return 404 for route without term (e.g. /search) and works fine with term (e.g. /search/123).

I ended up with splitting this route into two:

        routes.MapRoute(
            "search-empty",
            @"search",
            new {
                controller = MVC.Mobile.Name,
                action = MVC.Mobile.Actions.ActionNames.Search
            }
        );

        routes.MapRoute(
            "search",
            @"search/{term}",
            new {
                controller = MVC.Mobile.Name,
                action = MVC.Mobile.Actions.ActionNames.Search
            },
            new {
                term = @"^[0-9]*$"
            }
        );

Also I have tried to play with reg exp and define term with default value instead of optional parameter without any success.
Is anybody knows why it is working on windows and isn’t on linux?

  • 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-15T21:05:01+00:00Added an answer on June 15, 2026 at 9:05 pm

    The problem arises in the System.Web.Routing.Route.ProcessConstraint() method.

    Mono is only evaluating the regex if the value (as string) is not null or empty. If you’re accessing the route without any parameter the value is a UrlParameter instance (namely UrlParameter.Optional) and this as string is null. Thus the expression is never evaluated.

    To solve this issue you could implement your own Route object and handle things there differently. More on that in my blog post.

    And here is the mono implementation which causes the behavior. Look at the ProcessConstraintInternal() method. MatchConstraintRegex() is only called if the parameter value is not null or empty.

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

Sidebar

Related Questions

I have an ASP MVC3 application that runs fine (in VS 2010 debug) in
Right, I have been tasked with developing a new application in MVC3 that unfortunately
Assuming I have a ASP.NET MVC 3 application that runs in a web farm
I have an ASP.NET MVC3 application that I have built and it has two
I have a ASP.NET MVC3 application that handles time-consuming processes (copying a large file
i have created an mvc3 web application that uses forms based authentication. one part
In my MVC3 application, I have a queries class specific to each controller that
I have MVC3 web application running under IIS 7. During initialization in global.asax application
I have an existing MVC3 application and database that is on a SQL Server
I have an MVC3 application, I know that for relative paths, I can use

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.