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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:36:19+00:00 2026-05-31T05:36:19+00:00

I am using ASP.NET MVC 4 Beta with Web API – although I believe

  • 0

I am using ASP.NET MVC 4 Beta with Web API – although I believe the routing implementation has no significant differences from .NET 4.0 relevant to this question. MapHttpRoute, used in the code below, ships with MVC 4 and is an extension method that essentially performs the same function as MapRoute, but for WebApi controllers.

I have a legacy web serivce method for which I want create an ASP.NET route. The method currently has following signature:

NewsItemList ListNewsItems(string category, int maxResults)

It should be mapped by requests whose URIs look like this:

~/news?category=finance&maxResults=50

Neither, either or both query string parameters can be present.

I am struggling to find a way to define a route to support this method.

I used MapHttpRoute to register the route and set defaults for the controller and action values to the controller and method appropriately. Here are some templates I have tried with the outcome:

  • "news" captures "~/news" and binds to the method correctly, but
    won’t capture anything with a querystring.
  • "news{*query} is not
    allowed because you cannot have a catch-all unless it is exclusive to
    the Uri segment
  • "news{query}" captures the query string but doesn’t
    bind to the method

I’m looking for a way forwards that isn’t too radical a departure as this is an edge-case in the application. The solution has to fit in with many other existing routes. Ideally I’d like to avoid going down the Uri re-writer path as well.

  • 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-31T05:36:20+00:00Added an answer on May 31, 2026 at 5:36 am

    This was down to a problem in the way I was testing. I erroneously assumed that HttpRequestBase.AppRelativeCurrentExecutionFilePath includes the query string part of the request uri. It does not. When I corrected my Mock, everything started working.

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

Sidebar

Related Questions

I'm deciding between using ASP.NET MVC, or standard ASP.NET Web Forms with URL routing
I have an ASP.NET MVC (Beta 1) website that I'm using themes with. When
I'm using the MVC beta to write a simple application to understand ASP.Net MVC.
I Installed Microsoft's Asp.net MVC 2 using the Web PI (on Windows XP) but
I'm trying to get setup using the DataAnnotations validator in ASP.Net MVC 2.0 Beta,
I have ASP.NET MVC Beta on our web server running a few apps. My
My team is considering building our next web app using the ASP.NET MVC framework.
I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created
So far I've been using ASP.NET MVC 3 BETA. Everything was working fine till
I was using Html.RouteLink(LINKTEXT,RouteName,new RouteValueDictionary()) in asp.net MVC beta without problem, today I upgrade

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.