Wrong Request Match result is returning #33

Closed
opened 2025-12-29 08:21:16 +01:00 by adam · 6 comments
Owner

Originally created by @kailashravuri on GitHub (Jun 20, 2017).

Originally assigned to: @StefH on GitHub.

Hi - I downloaded the code and while running the ConsoleApplication Project inthe sulution with some changes i am getting some bizarre results.

In the attached sample code file - when i try to run the run application and accessing the URL from browser - like http://localhost:9091/search/query i am getting the result of path match for url "/testmatch".

If i register the url "/search/query" above "/testmatch" and try to browse http://localhost:9091/search/query i am getting the result of "/search/query" but if try "/testmatch" still getting the result of "search/query"

If i move the code up and down for registering urls, It is always returning the first one irrespective of path i am accessing from browser.

MainApp.txt

Originally created by @kailashravuri on GitHub (Jun 20, 2017). Originally assigned to: @StefH on GitHub. Hi - I downloaded the code and while running the ConsoleApplication Project inthe sulution with some changes i am getting some bizarre results. In the attached sample code file - when i try to run the run application and accessing the URL from browser - like http://localhost:9091/search/query i am getting the result of path match for url "/testmatch". If i register the url "/search/query" above "/testmatch" and try to browse http://localhost:9091/search/query i am getting the result of "/search/query" but if try "/testmatch" still getting the result of "search/query" If i move the code up and down for registering urls, It is always returning the first one irrespective of path i am accessing from browser. [MainApp.txt](https://github.com/WireMock-Net/WireMock.Net/files/1088825/MainApp.txt)
adam added the question label 2025-12-29 08:21:16 +01:00
adam closed this issue 2025-12-29 08:21:16 +01:00
Author
Owner

@phillee007 commented on GitHub (Jun 20, 2017):

Try removing the EnablePartialMapping line and see if that fixes it.

@phillee007 commented on GitHub (Jun 20, 2017): Try removing the EnablePartialMapping line and see if that fixes it.
Author
Owner

@StefH commented on GitHub (Jun 20, 2017):

There are some errors:

  1. Remove this line : server.SetBasicAuthentication("a", "b"); // this line means that you want to protect the server with basic authemtication

  2. Use WithPath instead of WithUrl

And WithBodyAsJson can be used more easily like:
WithBodyAsJson(new { value = "test" }

And

If i move the code up and down for registering urls, It is always returning the first one irrespective of path i am accessing from browser.

If you want to change prio, add AtPriority. See wiki here:
https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing-and-Request-Matching#stub-priority

@StefH commented on GitHub (Jun 20, 2017): There are some errors: 1. Remove this line : `server.SetBasicAuthentication("a", "b");` // this line means that you want to protect the server with basic authemtication 2. Use `WithPath` instead of `WithUrl` And `WithBodyAsJson` can be used more easily like: `WithBodyAsJson(new { value = "test" }` And > If i move the code up and down for registering urls, It is always returning the first one irrespective of path i am accessing from browser. If you want to change prio, add `AtPriority`. See wiki here: https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing-and-Request-Matching#stub-priority
Author
Owner

@kailashravuri commented on GitHub (Jun 22, 2017):

Hi @StefH
I need the authentication and i am passing user ID and password using postman. As you mentioned i removed AllowPartialMapping then i am getting result for "/search/query" but "No matching mapping found" for '/testpath'

@kailashravuri commented on GitHub (Jun 22, 2017): Hi @StefH I need the authentication and i am passing user ID and password using postman. As you mentioned i removed `AllowPartialMapping` then i am getting result for "/search/query" but "No matching mapping found" for '/testpath'
Author
Owner

@StefH commented on GitHub (Jun 22, 2017):

Did you change your code to use WithPath ?

@StefH commented on GitHub (Jun 22, 2017): Did you change your code to use `WithPath` ?
Author
Owner

@kailashravuri commented on GitHub (Jun 22, 2017):

@StefH yaa it looks like WithPath is working fine. Sorry for missing that last time. Thanks for helping me out.

@kailashravuri commented on GitHub (Jun 22, 2017): @StefH yaa it looks like `WithPath` is working fine. Sorry for missing that last time. Thanks for helping me out.
Author
Owner

@StefH commented on GitHub (Jun 22, 2017):

Ok. If you have more questions or ideas, please ask.

@StefH commented on GitHub (Jun 22, 2017): Ok. If you have more questions or ideas, please ask.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#33