Feature: Support running WireMock.Net as a sub-app in IIS #114

Closed
opened 2025-12-29 14:22:47 +01:00 by adam · 12 comments
Owner

Originally created by @DavidKorn on GitHub (Jun 28, 2018).

Is there an easy way to stand up WireMock.Net as a web app hosted on an internal IIS server? Our build & test pipeline pushes web apps to our various test environments, and it would make life a lot easier to deploy WireMock to those test environments in the same way. The goal would be to be able to hit http://staging.ourCo.com/mock/whatever and have WireMock generate the response to the /whatever path.

Meanwhile http://staging.ourCo.com/fancyapp would be a different site on the same IIS.

Originally created by @DavidKorn on GitHub (Jun 28, 2018). Is there an easy way to stand up WireMock.Net as a web app hosted on an internal IIS server? Our build & test pipeline pushes web apps to our various test environments, and it would make life a lot easier to deploy WireMock to those test environments in the same way. The goal would be to be able to hit ```http://staging.ourCo.com/mock/whatever``` and have WireMock generate the response to the ```/whatever``` path. Meanwhile ```http://staging.ourCo.com/fancyapp``` would be a different site on the same IIS.
adam added the question label 2025-12-29 14:22:47 +01:00
adam closed this issue 2025-12-29 14:22:47 +01:00
Author
Owner

@StefH commented on GitHub (Jun 28, 2018):

You can host WireMock.Net as a web-api, this is described at https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-(Azure)-Web-App.

Does this help you?

@StefH commented on GitHub (Jun 28, 2018): You can host WireMock.Net as a web-api, this is described at https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-(Azure)-Web-App. Does this help you?
Author
Owner

@DavidKorn commented on GitHub (Jul 1, 2018):

@StefH Thanks for the pointer! I really appreciate all the samples. I had had some circumstantial issues early on that led me astray, but that sample works for me in IIS once I got my kinks worked out.

I still have one related kink: I'm hosting WireMock as a sub app on IIS, but the sub app base directory is still prepending to the request and throwing off the matching. For example, the sub app is in /mock, and if I hit http://localhost/mock/__admin/settings, the request being matched is still /mock/__admin/settings rather than /__admin/settings. I haven't yet tracked this down in the code, but I'm wondering if there is just some setting I need to set?

@DavidKorn commented on GitHub (Jul 1, 2018): @StefH Thanks for the pointer! I really appreciate all the samples. I had had some circumstantial issues early on that led me astray, but that sample works for me in IIS once I got my kinks worked out. I still have one related kink: I'm hosting WireMock as a sub app on IIS, but the sub app base directory is still prepending to the request and throwing off the matching. For example, the sub app is in ```/mock```, and if I hit ```http://localhost/mock/__admin/settings```, the request being matched is still ```/mock/__admin/settings``` rather than ```/__admin/settings```. I haven't yet tracked this down in the code, but I'm wondering if there is just some setting I need to set?
Author
Owner

@StefH commented on GitHub (Jul 1, 2018):

Currently it seems that WireMock.Net does not yet support running in a sub-app in IIS. The easiest solution would be that the sub-app folder name would be configured using the FluentMockServerSettings.

I'll take a look if I can build that.

Edit...
Actually the solution should cover two scenarios:

  1. When running in IIS, it should be possible to define the sub-app folder, in order to determine the correct starting point in the path.
  2. When running normally, it should also be possible to define a sub-app folder, so that it can run at /test1 and also at /test2. However I'm not 100% this will work.
@StefH commented on GitHub (Jul 1, 2018): Currently it seems that WireMock.Net does not yet support running in a sub-app in IIS. The easiest solution would be that the sub-app folder name would be configured using the FluentMockServerSettings. I'll take a look if I can build that. _Edit..._ Actually the solution should cover two scenarios: 1. When running in IIS, it should be possible to define the sub-app folder, in order to determine the correct starting point in the path. 2. When running normally, it should also be possible to define a sub-app folder, so that it can run at `/test1` and also at `/test2`. However I'm not 100% this will work.
Author
Owner

@StefH commented on GitHub (Jul 1, 2018):

Hello @DavidKorn ,

You can review branch https://github.com/WireMock-Net/WireMock.Net/tree/iis_fix which includes the fix + updated example.

And I've created a preview NuGet, please test this and give me feedback.
https://www.nuget.org/packages/WireMock.Net.StandAlone/1.0.4.5-preview-01
and
https://www.nuget.org/packages/WireMock.Net/1.0.4.5-preview-01

@StefH commented on GitHub (Jul 1, 2018): Hello @DavidKorn , You can review branch https://github.com/WireMock-Net/WireMock.Net/tree/iis_fix which includes the fix + updated example. And I've created a preview NuGet, please test this and give me feedback. https://www.nuget.org/packages/WireMock.Net.StandAlone/1.0.4.5-preview-01 and https://www.nuget.org/packages/WireMock.Net/1.0.4.5-preview-01
Author
Owner

@DavidKorn commented on GitHub (Jul 1, 2018):

Thanks @StefH I'll take a look.

Edit: Removed pointless comment. I misunderstood your plan. :) I'll keep reviewing and testing but initially this looks great.

@DavidKorn commented on GitHub (Jul 1, 2018): Thanks @StefH I'll take a look. Edit: Removed pointless comment. I misunderstood your plan. :) I'll keep reviewing and testing but initially this looks great.
Author
Owner

@DavidKorn commented on GitHub (Jul 2, 2018):

Nicely done @StefH . It works perfectly in all my local testing. I'll work with my devops in the next few days to get the preview rolled out and I'll report back if there's any surprises. Thanks again for all your work to get make this tool so great.

Minor thing: The readme.md in the sample web project references two publish profiles, but those are missing and probably getting git-ignored in your commits. (Even more minor: That csproj includes the wwwroot folder but it doesn't exist from the repo, so that looks a little broken in solution explorer.)

@DavidKorn commented on GitHub (Jul 2, 2018): Nicely done @StefH . It works perfectly in all my local testing. I'll work with my devops in the next few days to get the preview rolled out and I'll report back if there's any surprises. Thanks again for all your work to get make this tool so great. Minor thing: The readme.md in the sample web project references two publish profiles, but those are missing and probably getting git-ignored in your commits. (Even more minor: That csproj includes the wwwroot folder but it doesn't exist from the repo, so that looks a little broken in solution explorer.)
Author
Owner

@DavidKorn commented on GitHub (Jul 2, 2018):

It looks like the AbsoluteUrl is wrong now. It doesn't include the subpath.

@DavidKorn commented on GitHub (Jul 2, 2018): It looks like the AbsoluteUrl is wrong now. It doesn't include the subpath.
Author
Owner

@StefH commented on GitHub (Jul 2, 2018):

Hello David,

1]
I've fixed the minors, see that same branch.

2]
I've fixed the AbsoluteUrl. So the request is now logged like:

"Path": "/param2",
"AbsolutePath": "/wiremock/param2",
"Url": "http://localhost/param2?key=testdd",
"AbsoluteUrl": "http://localhost/wiremock/param2?key=testdd",

I've also added the AbsolutePath, AbsoluteUrl and AbsolutePathSegments to the request, so they can also be used in the handlebars substitution.

3]
New NuGet is uploaded : 1.0.4.5-preview-02

@StefH commented on GitHub (Jul 2, 2018): Hello David, 1] I've fixed the minors, see that same branch. 2] I've fixed the AbsoluteUrl. So the request is now logged like: ``` js "Path": "/param2", "AbsolutePath": "/wiremock/param2", "Url": "http://localhost/param2?key=testdd", "AbsoluteUrl": "http://localhost/wiremock/param2?key=testdd", ``` I've also added the AbsolutePath, AbsoluteUrl and AbsolutePathSegments to the request, so they can also be used in the handlebars substitution. 3] New NuGet is uploaded : 1.0.4.5-preview-02
Author
Owner

@DavidKorn commented on GitHub (Jul 4, 2018):

Quick update: We are testing on 1.0.4.5 preview 2, and so far things continue to work well.

You mentioned fixing the minor issues, but I don't think the publish profiles referenced in the readme.md are working. For me those get git-ignored, maybe that's why.

@DavidKorn commented on GitHub (Jul 4, 2018): Quick update: We are testing on 1.0.4.5 preview 2, and so far things continue to work well. You mentioned fixing the minor issues, but I don't think the publish profiles referenced in the readme.md are working. For me those get git-ignored, maybe that's why.
Author
Owner

@StefH commented on GitHub (Jul 4, 2018):

I thought that I did override the ignore... I will take a look, but this will be after some time. No access to code right now.

@StefH commented on GitHub (Jul 4, 2018): I thought that I did override the ignore... I will take a look, but this will be after some time. No access to code right now.
Author
Owner

@DavidKorn commented on GitHub (Jul 10, 2018):

@StefH I think you can close this issue whenever you like. The main feature here is working great for us now.

@DavidKorn commented on GitHub (Jul 10, 2018): @StefH I think you can close this issue whenever you like. The main feature here is working great for us now.
Author
Owner

@StefH commented on GitHub (Jul 10, 2018):

This weekend I'll see if the ignored files can be added to git. And I will create a official NuGet.

@StefH commented on GitHub (Jul 10, 2018): This weekend I'll see if the ignored files can be added to git. And I will create a official NuGet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#114