mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
How to load 'ProxyAndRecordSettings' from 'appsettings.json' ? #409
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PrzemekScott on GitHub (Mar 9, 2022).
I've experimented with WM stand alone version locally, with such settings:
Now wanted to experiment with WM as web app and then set it on Azure, but not sure how to implement 'ProxyAndRecordSetting' in appsettings file. When I have it like below:

I'm getting such error:
System.InvalidOperationException: Cannot create instance of type 'WireMock.Settings.IProxyAndRecordSettings' because it is either abstract or an interface.The way I run WM with configuration is from one of 'examples projects' :

thx
@StefH commented on GitHub (Mar 9, 2022):
@PrzemekScott
I don't think this is possible.
I'll investigate why I decided to use an interface instead of a class, and see if I can remove the interface.
@PrzemekScott commented on GitHub (Mar 9, 2022):
I see.
Is then any other way to run WM on Azure in "proxying mode" (when needed - less often) and in "matching mode" (when needed - most of the time) ?
@StefH commented on GitHub (Mar 9, 2022):
Only workaround for now is to split the settings in two sections:
And then do two calls:
@StefH commented on GitHub (Mar 9, 2022):
@PrzemekScott
I've created a preview version which only has classes for settings; no interfaces anymore.
Preview version =
1.4.37-ci-15956.See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
https://github.com/WireMock-Net/WireMock.Net/pull/736
@PrzemekScott commented on GitHub (Mar 10, 2022):
Thanks @StefH. Will give it a try.
@PrzemekScott commented on GitHub (Mar 10, 2022):
@StefH ,
Thanks for that change. It works well, starting server with all settings from the appsettings.json file"
Yet, there is one thing which I do not understand.
When I Run the App - I'm using JB Rider as my IDE - in next several seconds the browser is opened with this url as below:
@StefH commented on GitHub (Mar 10, 2022):
Can you provide your full project?
@PrzemekScott commented on GitHub (Mar 10, 2022):
Unfortunately @StefH, I've started WM project as a POC under one of test automation projects in my organisation and all of such projects are set as 'Internal', it is also bonded with our internal tools, accesses, so, unfortunately I can't share it.
What we’ve checked is that colleagues working with Visual Studio IDE are not facing this “action” of opening browser when ‘Program’ is run - it's only happening when "Program" is run in my JB Rider (on macOS).
@StefH commented on GitHub (Mar 10, 2022):
Can you share your appsettings.json and the startup code?
From that I can try to reproduce it
@PrzemekScott commented on GitHub (Mar 11, 2022):
Sure I can share files.
Archive.zip
@StefH commented on GitHub (Mar 11, 2022):
When running as:

It just works fine?

@PrzemekScott commented on GitHub (Mar 11, 2022):
So as it also did for my colleagues using Visual Studio. I will try to contact Jet Brain and as for some support. Maybe, just an assumption, that when JB Rider is Run(ning) web app type App, it opens it on some predefined port. But I couldn't find it in settings.
Anyway, thank you StefH for help and changing interface to class in appsettings. I think we can consider this Question as closed.
@PrzemekScott commented on GitHub (Mar 11, 2022):
;) actually I've just found it in launchSettings: