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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:54:35+00:00 2026-05-13T14:54:35+00:00

This is ASP.NET MVC v1 (not using the v2 yet) I have a route

  • 0

This is ASP.NET MVC v1 (not using the v2 yet)

I have a route entry like this:

            routes.MapRoute(
            "Srp",
            "soeg-{searchQuery}/{listingType}",
            new { controller = "Srp", action = "Search", listingType = string.Empty },
            new { listingType = "privat|forhandler|"}
            );

and an action to match it:

        public ActionResult Search(QueryParameters queryParameters)

It works perfectly – the mvc framework knows to map the searchQuery and listingType onto the two properties of the QueryParameters object with the same names.

My problem is unit testing. I’m using Mvccontrib project and LOVING the ShouldMapTo method:

        [Test]
    public void RegisterSrpRoutes_SoegWithKeywordAndValidListingType_ShouldMapCorrectly()
    {
        var queryParameters = new QueryParameters {SearchQuery = "hest", ListingType = "privat"};
        "~/soeg-hest/privat".ShouldMapTo<SrpController>(controller => controller.Search(queryParameters));
    }

It doesn’t work though! I used to have specific parameters on my action like this:

        public ActionResult Search(string searchQuery, string listingType)

which worked (obviously the unittest would try and map to Search with two parameters (strings) instead of this one object.

Does anyone have an idea of how to solve the problem, short of going back to writing all properties as parameters. The mvc automapping of properties rocks, but i’m hoping there is some way i can have mvccontribs testhelper work with that 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-13T14:54:35+00:00Added an answer on May 13, 2026 at 2:54 pm

    It’s been a while since I looked at this code, but I believe that it does a .Equals call on the parameter you send. For primitive types this is easy, but for you parameter object, try implementing the Equals override and have it test the equality of each of the properties.

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

Sidebar

Related Questions

I know this site is written using ASP.Net MVC and I do not see
Using asp.net MVC I'd like to do this inside a view: <%= Html.TextBox(textbox1, null,
is it possible to create something like this i ASP.NET MVC beta 1 i
I'm new to ASP.NET MVC so this may be a stupid question. I have
I am trying to learn ASP.NET MVC and I hit this problem: I have
I have an ASP.NET MVC 3 application with some Facebook integration using the Facebook
Im looking to create a web application using ASP.NET MVC or PHP (not decided
This is somewhat asp.net MVC related only for example purposes but I was hoping
ASP.NET MVC has been discussed on this forum a few times. I'm about to
ASP.NET MVC - what is this in VB.NET? Html.TextBox( name, null, new { @class

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.